Unspace (String function): Difference between revisions
Jump to navigation
Jump to search
m (Luc should love the italicizaton) |
|||
Line 10: | Line 10: | ||
===Syntax Terms=== | ===Syntax Terms=== | ||
<dl> | <dl> | ||
<dt>%outStr | <dt><i>%outStr</i> | ||
<dd>A variable to receive the string result of the Unspace method. | <dd>A variable to receive the string result of the Unspace method. | ||
<dt>string | <dt><i>string</i> | ||
<dd>The input string or Longstring. | <dd>The input string or Longstring. | ||
<dt>Spaces=chars | <dt>Spaces=<i>chars</i> | ||
<dd>The optional Spaces argument (name required) is a string that specifies the set of characters considered to be whitespace. The default set is the blank character. | <dd>The optional Spaces argument (name required) is a string that specifies the set of characters considered to be whitespace. The default set is the blank character. | ||
Line 20: | Line 20: | ||
*There is no separator character. | *There is no separator character. | ||
*The first character of the string is the replacement space character: a single one of these is substituted for each sequence (which may be one) of non-leading, non-trailing Spaces characters in the method object string. | *The first character of the string is the replacement space character: a single one of these is substituted for each sequence (which may be one) of non-leading, non-trailing Spaces characters in the method object string. | ||
<dt>Leading=bool | <dt>Leading=<i>bool</i> | ||
<dd>The optional Leading argument (name required) is a Boolean value that specifies whether to strip all leading whitespace characters. The default is ''''True'''', strip leading whitespace. | <dd>The optional Leading argument (name required) is a Boolean value that specifies whether to strip all leading whitespace characters. The default is ''''True'''', strip leading whitespace. | ||
<dt>Trailing=bool | <dt>Trailing=<i>bool</i> | ||
<dd>The optional Trailing argument (name required) is a Boolean value that specifies whether to strip all trailing whitespace characters. | <dd>The optional Trailing argument (name required) is a Boolean value that specifies whether to strip all trailing whitespace characters. | ||
The default is ''''True'''', strip trailing whitespace. | The default is ''''True'''', strip trailing whitespace. | ||
<dt>Compress=bool | <dt>Compress=<i>bool</i> | ||
<dd>The optional Compress argument (name required) is a Boolean value that specifies whether to collapse non-leading, non-trailing sequences of spaces to single spaces. The default is ''''True'''', collapse such sequences. | <dd>The optional Compress argument (name required) is a Boolean value that specifies whether to collapse non-leading, non-trailing sequences of spaces to single spaces. The default is ''''True'''', collapse such sequences. | ||
Revision as of 23:43, 11 November 2010
This intrinsic function removes the whitespace characters from the method object string 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
The Unspace function is available as of version 7.3 of the Sirius Mods.
Unspace syntax
%outStr = string:Unspace( [Spaces=chars] [, Leading=bool] [, Trailing=bool] [, Compress=bool] )
Syntax Terms
- %outStr
- A variable to receive the string result of the Unspace method.
- string
- The input string or Longstring.
- Spaces=chars
- The optional Spaces argument (name required) is a string that specifies the set of characters considered to be whitespace. The default set is the blank character.
If you specify multiple Spaces characters:
- There is no separator character.
- The first character of the string is the replacement space character: a single one of these is substituted for each sequence (which may be one) of non-leading, non-trailing Spaces characters in the method object string.
- Leading=bool
- The optional Leading argument (name required) is a Boolean value that specifies whether to strip all leading whitespace characters. The default is 'True', strip leading whitespace.
- Trailing=bool
- The optional Trailing argument (name required) is a Boolean value that specifies whether to strip all trailing whitespace characters. The default is 'True', strip trailing whitespace.
- Compress=bool
- The optional Compress argument (name required) is a Boolean value that specifies whether to collapse non-leading, non-trailing sequences of spaces to single spaces. The default is 'True', collapse such sequences.
Usage Notes
- Duplicate Spaces characters are tolerated and do not affect the result.
Examples
The following are example Unspace statements:
%ls is longstring %ls = ' so me chars ' PrintText {~} = {%ls:unspace()} PrintText {~} = {%ls:unspace(Spaces='X ')} PrintText {~} = {%ls:unspace(leading=false)} PrintText {~} = {%ls:unspace(trailing=false)} PrintText {~} = {%ls:unspace(compress=false)}
The results are respectively:
%ls:unspace() = so me chars %ls:unspace(Spaces='X ') = soXmeXchars %ls:unspace(leading=false) = so me chars %ls:unspace(trailing=false) = so me chars %ls:unspace(compress=false) = so me chars