FUNCTION:  String.squeeze

String.squeze(string)
 
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.
 
The mandatory string parameter can be any string containing one or more of any combination of characters and white spaces.
 
Code for SqueezeExample.wml
<?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.wmls
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");
};


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information