O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

elements — Return the number of items in a list that is stored as a string

Usage

String.elements(str, sep)

str : String

sep : String

Description

(See elementAt( )’s description for an explanation of how a string is processed as a list of “elements.”)

Returns the number of elements in str. Note that an empty str is a valid list containing a single element: the empty string.

Returns invalid if either str or sep can’t be converted to a string or if sep is the empty string.

Examples

String.elements("1;2;3;4", ";")

returns integer 4

String.elements("1;2;3;4", ";foo")

returns integer 4

String.elements("aa bbb c dd e", " ")

returns integer 5

String.elements("x,,y,,,,z", ",")

returns integer 7

String.elements("", "x")

returns integer 1

String.elements("foo", "")

returns invalid

String.elements(invalid, "x")

returns invalid

String.elements("foo", invalid)

returns invalid

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required