The Wireless Universal Resource File

10.4 Which functions are available in the WMLscript String library?

The following functions are available in the String library. Note that this is meant as a basic introduction and a quick reference. The authoritative source on WMLscript is WAPforum and the latest approved WMLscript reference is available here.

The functions in this section are accessed by String.functionName

String indexes start at 0, i.e. the first character in a string is at position 0.

length(string) returns length of string

isEmpty(string) returns true if string is empty

charAt(string,index) returns a string containing the character as position index in string

subString(string,start,length) returns a string containing all characters in string from position start and count characters forward

find(string,substring) returns the position where substring is found in string. If no match, -1 is returned

replace(string,oldsubstring,newsubstring) replaces all occurrences of oldsubstring in string with newsubstring

elements(string,character) returns the number of elements present in string separated by character

elementAt(string,index,character) returns the index'th element in string separated by character

removeAt(string,index,character) returns string after the index'th element has been removed separated by character

replaceAt(string,element,index,character) returns string after the index'th element has been replaced by element separated by character

insertAt(string,element,index,character) returns string after the element has been inserted in the index'th element separated by character

squeeze(string) returns string after all whitespaces inside string has been removed

trim(string) returns string after all leading and trailing whitespaces has been removed

compare(string1,string2) compares string1 with string2 and returns -1 if less, 0 if equal or 1 if greater

toString(number) returns number converted to a string.

[ Main ]   [ 10 - WMLscript in detail ]