UnicodeUnspace (Unicode function): Difference between revisions
m (→Syntax terms) |
mNo edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
<tr><th><var>Spaces</var></th> | <tr><th><var>Spaces</var></th> | ||
<td><var>Spaces</var> is an optional, [[Notation conventions for methods#Named parameters|name required]], parameter that is a <var>Unicode</var> string that specifies the set of characters considered to be whitespace. The default set is the blank space (< | <td><var>Spaces</var> is an optional, [[Notation conventions for methods#Named parameters|name required]], parameter that is a <var>Unicode</var> string that specifies the set of characters considered to be whitespace. The default set is the blank space (<tt>' '</tt>) character.</td></tr> | ||
<tr><th><var>Leading</var></th> | <tr><th><var>Leading</var></th> | ||
Line 30: | Line 28: | ||
<tr><th><var>Compress</var></th> | <tr><th><var>Compress</var></th> | ||
<td><var>Compress</var> is an optional, name required, parameter that is a <var>Boolean</var> value that specifies whether to collapse each sequence of spaces to a single space. The default is <var>True</var>, collapse such sequences.</td></tr> | <td><var>Compress</var> is an optional, name required, parameter that is a <var>Boolean</var> value that specifies whether to collapse each sequence of spaces to a single space (the replacement space is the first character in the <var>Spaces</var> argument). The default is <var>True</var>, collapse such sequences.</td></tr> | ||
</table> | </table> | ||
Line 39: | Line 37: | ||
==Examples== | ==Examples== | ||
The following fragment returns the contents of the Unicode variable <code>%in</code> with leading and trailing whitespace removed and with intermediate sequences of whitespace replaced by a single space character, where <i>whitespace</i> is a sequence of space, tab, linefeed, and carriage return characters: | |||
<p class=code>%out = %in:unicodeUnspace(spaces='&#x20;&#x09;&#x0a;&#x0d;':u)</p> | |||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeUnspace footer}} | {{Template:Unicode:UnicodeUnspace footer}} |
Latest revision as of 20:16, 6 November 2012
Remove whitespace characters from the string (Unicode class)
[Introduced in Sirius Mods 8.0]
The UnicodeUnspace intrinsic function removes the whitespace characters from the Unicode string method object, and it returns the resulting string. Options are available to:
- Define which character or characters are to be interpreted as whitespace
- Remove leading whitespace, trailing whitespace, both, or neither
- Collapse to a single whitespace character any sequences of non-leading, non-trailing whitespace
Syntax
%outUnicode = unicode:UnicodeUnspace[( [Spaces= string], [Leading= boolean], - [Trailing= boolean], - [Compress= boolean])]
Syntax terms
%outUnicode | A Unicode variable to receive the result of the UnicodeUnspace function. |
---|---|
unicode | The method object Unicode string. |
Spaces | Spaces is an optional, name required, parameter that is a Unicode string that specifies the set of characters considered to be whitespace. The default set is the blank space (' ') character. |
Leading | Leading is an optional, name required, parameter that is a Boolean value that specifies whether to strip all leading whitespace characters. The default is True, strip leading whitespace. |
Trailing | Trailing is an optional, name required, parameter that is a Boolean value that specifies whether to strip all trailing whitespace characters. The default is True, strip trailing whitespace. |
Compress | Compress is an optional, name required, parameter that is a Boolean value that specifies whether to collapse each sequence of spaces to a single space (the replacement space is the first character in the Spaces argument). The default is True, collapse such sequences. |
Usage notes
- Duplicate Spaces characters are tolerated and do not affect the result.
Examples
The following fragment returns the contents of the Unicode variable %in
with leading and trailing whitespace removed and with intermediate sequences of whitespace replaced by a single space character, where whitespace is a sequence of space, tab, linefeed, and carriage return characters:
%out = %in:unicodeUnspace(spaces=' 	

':u)