FUNCTION: String.trim
String.trim(string)
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"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
trim example
</p>
<do type="accept">
<go href="TrimExample.wmls#findtrim()"
/>
</do>
</card>
<card id="card2">
<p>
string = $(strng)
<br />
trim string = $(trimstrng)
</p>
</card>
</wml>
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);
WMLBrowser.go("TrimExample.wml#card2");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
|