Name
squeeze — Convert all whitespace within a string to a single space
Usage
String.squeeze(str)
: Stringstr
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 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.