Name

squeeze — Convert all whitespace within a string to a single space

Usage

String.squeeze(str)

str : String

Description

Returns a new string in which all sequences of whitespace characters in str have been reduced to a single space. Returns invalid if str can’t be converted to a string.

Note that leading and trailing spaces aren’t stripped completely; they’re converted to single spaces. See the trim( ) function.

Examples

String.squeeze("foo")

returns string "foo"

String.squeeze(" Once upon a time ")

returns string " Once upon a time"

String.squeeze(invalid)

returns invalid

Get Learning WML, and WMLScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.