Removes all leading and ending white space in a 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.
<?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.wml
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");
};
Code for TrimExample.wmls