STANDARD LIBRARY:  String

The String Library contains sixteen functions that can be used to manipulate a string.
 
By definition, a string is an array of characters. The length of a string (size of the array) is the total number of characters in the array, including white space. Each character in the string has an index position, where the first character is at position zero. A string can also be composed of a series of elements that are delineated by separators. A separator can be any character. Certainly, the most commonly used separator is a blank space, which is one of six types of white space recognized by WMLScript.
 
The six types of white space are:
 
Character Description
CR Carriage Return
FF Form Feed
LF Line Feed
SP Blank Space
TAB Horizontal tab
VT Vertical Tab

 
The library and function names are case sensitive.
 
The fifteen functions are:
 
charAt
Returns the character at the specified location in the string.
 
Syntax: String.charAt(string, index)
 
compare
Compares and ranks two strings.
 
Syntax: String.compare(string1, string2)
 
elementAt
Returns the specified portion of a string.
 
Syntax: String.elementAt(string, index, separator)
 
elements
Returns the number of occurrences of a specified character element.
 
Syntax: String.elements(string, separator)
 
find
Returns the location of a specified substring in a string.
 
Syntax: String.find(string, subString)
 
format
Converts a given value to a string using a specified format.
 
Syntax: String.format(format, string)
 
insertAt
Inserts an element and separator into a string.
 
Syntax: String.insertAt(string, element, index, separator)
 
isEmpty
Determines if a string is empty.
 
Syntax: String.isEmpty(string)
 
length
Returns the length of the string.
 
Syntax: String.length(string)
 
removeAt
Remove a specified substring from a string.
 
Syntax: String.removeAt(string, index, separator)
 
replace
Replaces all occurrences of a substring with a new substring.
 
Syntax: String.replace(string, oldSubString, newSubString)
 
replaceAt
Replaces a specified occurrence of a substring with a new substring.
 
Syntax: String.replaceAt(string, element, index, separator)
 
squeeze
Removes extra white space.
 
Syntax: String.squeeze(string)
 
subString
Creates a new string by selecting a substring out of an existing string.
 
Syntax: String.subString(string, startIndex, length)
 
toString
Converts a given value to a string.
 
Syntax: String.toString(value)
 
trim
Removes all leading and ending white space in a string.
 
Syntax: String.trim(string)
 


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information