Removes extra white space.
The
String.squeeze function removes all extra white spaces out of a
given string. All occurrences of consecutive white space characters are
reduced down to one white space character. The modified string is
returned.
You can use the String.trim
function to remove all leading and trailing white spaces in a string.
<?xml
version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD
WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
squeeze
example
</p>
<do type="accept">
<go
href="SqueezeExample.wmls#findsqueeze()" />
</do>
</card>
<card id="card2">
<p>
old string = $(oldstrng)
<br />
new
string = $(newstrng)
</p>
</card>
</wml>Code for SqueezeExample.wml
extern function
findsqueeze()
{
var oldstr =
Dialogs.prompt("Enter a string", "");
var
newstr = String.squeeze(oldstr);
WMLBrowser.setVar("oldstrng", oldstr);
WMLBrowser.setVar("newstrng", newstr);
WMLBrowser.go("SqueezeExample.wml#card2");
};
Code for SqueezeExample.wmls