FUNCTION:  String.trim

The String.trim function takes the given string and removes all of the leading and trailing white spaces (if any). No white space inside the string (between the characters and elements) is removed. This function returns the modified string.
You can use the String.squeeze function to remove extra white spaces between the characters and elements.
The mandatory value parameter can be any combination of zero or more characters (letters, numbers, decimal points, etc.) and white spaces. If the value is an empty string, an empty string is returned.
Code for TrimExample.wml
<?xml version="1.0"?>

<card id="card1">
   trim example
   <do type="accept">
      <go href="TrimExample.wmls#findtrim()" />

<card id="card2">
   string = $(strng)
   <br />
   trim string = $(trimstrng)


Code for TrimExample.wmls
extern function findtrim()
   var str = Dialogs.prompt("Enter a string", "");
   var trimstr = String.trim(str);
   WMLBrowser.setVar("strng", str);
   WMLBrowser.setVar("trimstrng", trimstr);

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