Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By brutzler
#29957 Hi, anyone tested the "String.substring()" function? I do not get it working. "String.replace" is fine. Want to eleminate redundate spaces of HTML-code in a string before sending:
Code: Select all while (html_index.substring(0) == "  ") {
   html_index.replace("  "," ");
 }
User avatar
By eduperez
#29971 I honestly think that the documentation for the String.substring() method could hardly be worse...

String.substring() does not "looks for a given substring from the position given to the end of the string"; it cuts a part of the string and lets you do whatever you want with that part. So, someString.substring(0) returns exactly the same as someString, because "someString.substring(0)" means "cut from the first character of someString, up to the end of someString".

In your code, (html_index.substring(0) == " ") is only true when html_index is exactly " "; far from what you need.