FUNCTION:  String.squeeze

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"?>

<card id="card1">
   squeeze example
   <do type="accept">
      <go href="SqueezeExample.wmls#findsqueeze()" />

<card id="card2">
   old string = $(oldstrng)
   <br />
   new string = $(newstrng)


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);

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