WMLScript elementAt() functie
De elementAt() functie scheidt de string op elementen en retourneert het element op de gespecificeerde indexpositie.
Syntaxis
n = String.elementAt(string, index, separator)
Componenent | Beschrijving |
---|---|
n | De string die door de functie wordt geretourneerd. |
string | De te ontleden string. |
index | Een integer die het gedeelte definieert dat wordt geretourneerd. |
separator | Separator of the string separator. |
Note:If index is negative, it returns the first element. If the value of index is too large, it returns the last element.
Example
var a= String.elementAt("Visit CodeW3C.com today",0," "); var b= String.elementAt("Visit CodeW3C.com today",1," "); var c= String.elementAt("Visit CodeW3C.com today",2," "); var d= String.elementAt("Apples+Bananas",0,"+"); var e= String.elementAt("Apples+Bananas",1,"+"); var f= String.elementAt("Apples+Bananas",5,"+");
Result
a = "Visit" b = "W3School" c = "today" d = "Apples" e = "Bananas" f = "Bananas"