Remove a specified substring from a string.
The
String.removeAt function takes the given string, removes the
element at the given index, removes the given separator, and returns
the modified string.
This function treats a
string as an array composed of elements delimited by a separator that
is composed of one or more specified characters (including white
space). The first index position is numbered zero and the last index
position is the total number of the elements minus one. The total
number of elements in the string can be found by using the
String.elements function.
You can
insert new elements using the String.insertAt function.
<?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>
removeAt
example
</p>
<do type="accept">
<go
href="RemoveAtExample.wmls#findremoveat()" />
</do>
</card>
<card id="card2">
<p>
string = $(oldstring)
<br />
index =
$(index)
<br />
separator = $(separator)
<br />
new
string = $(newstring)
</p>
</card>
</wml>Code for RemoveAtExample.wml
extern function
findremoveat()
{
var oldstr =
Dialogs.prompt("Enter a string", "Hello wireless world!");
var indx = Dialogs.prompt("Enter an index",
"1");
var sep = Dialogs.prompt("Enter a
separator", " ");
var newstr = String.removeAt(oldstr, indx, sep);
WMLBrowser.setVar("oldstring", oldstr);
WMLBrowser.setVar("index", indx);
WMLBrowser.setVar("separator", sep);
WMLBrowser.setVar("newstring", newstr);
WMLBrowser.go("InsertAtExample.wml#card2");
};
Code for RemoveAtExample.wmls