Returns the specified string with extra white spaces removed.
Each sequence of the of contiguous whitespace will be "collapsed", that is reduced to one or two characters according to the following rules:
Parameters:
s
The source string
trim
Specifies whether to remove both leading and trailing white space.When
false
, the leading and trailing white space will not be removed completely but rather collapsed (as explained above).
trimLeft
Specifies whether to remove leading white space.When
false
, the leading white space will not be removed completely but rather collapsed (as explained above).
trimRight
Specifies whether to remove trailing white space (defaulttrue
).When
false
, the trailing white space will not be removed completely but rather collapsed (as explained above).
Note:
When no trim parameters are specified, by default both left and right trimmings will be assumed astrue
. That is,is the same as the callcollapseSpaces (s)
collapseSpaces (s, true)