String Library

The String library contains a set of string functions. In WMLScript, a string is essentially an array of characters, the first element of which is at offset 0.

charAt

Description: Returns the character at the specified position in a string.

Syntax: String.charAt(string,index)

Example: The following example returns the first letter of a user's name:

// Get initial
var initial=String.charAt(first_name, 0);

compare

Description: Compares two strings. Returns 1 if first string is greater than the second string, 0 if both strings are the same, or -1 if first string is less than the first string.

Syntax: String.compare(string1,string2)

Example: The following example (part of a sorting routine) compares two strings and switches them ...

Get WAP Development with WML and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.