WMLScript elements() Function

The elements() function of WMLScript returns the number of times the specified value appears in the string.

Syntax

n = String.elements(string, separator)
Component Description
n The number of times the string specified in separator appears in the string string.
String The string to be searched.
Separator The string value searched in the string.

Example

var a = String.elements("Visit CodeW3C.com!", "i");
var b = String.elements("Visit CodeW3C.com!", "V");
var c = String.elements("Visit CodeW3C.com!", " ");

Result

a = 2
b = 1
c = 1