Unspace (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{Template:String:Unspace subtitle}}
This [[Intrinsic classes|intrinsic]] function removes the whitespace characters from               
This [[Intrinsic classes|intrinsic]] function removes the whitespace characters from               
the method object string and it returns the resulting string. Options are available to:             
the method object string and it returns the resulting string. Options are available to:             
Line 6: Line 8:
                                                                                                    
                                                                                                    
The Unspace function is available as of version 7.3 of the [[Sirius Mods]].                         
The Unspace function is available as of version 7.3 of the [[Sirius Mods]].                         
===Unspace syntax===                                                                             
==Syntax==
  %outStr = string:Unspace( [Spaces=chars] [, Leading=bool] [, Trailing=bool] [, Compress=bool] )
{{Template:String:Unspace syntax}}
===Syntax Terms===                                                                                
===Syntax terms===
<dl>                                                                                               
<dl>                                                                                               
<dt><i>%outStr</i>   
<dt><i>%outStr</i>   
Line 29: Line 31:
                                                                                                  
                                                                                                  
</dl>                                                                                             
</dl>                                                                                             
===Usage Notes===                                                                              
==Usage notes==
*Duplicate Spaces characters are tolerated and do not affect the result.
*Duplicate Spaces characters are tolerated and do not affect the result.
*Prior to Version 7.8 of the ''Sirius Mods'', Unspace compressed a string consisting entirely of whitespace characters to a single whitespace character. As of version 7.8 (and also in version 7.7 maintenance), Unspace converts a string of whitespace characters to a null string. The version 7.8 result of <tt>PrintText {~} = X{'    ':unspace}X</tt> is:
*Prior to Version 7.8 of the ''Sirius Mods'', Unspace compressed a string consisting entirely of whitespace characters to a single whitespace character. As of version 7.8 (and also in version 7.7 maintenance), Unspace converts a string of whitespace characters to a null string. The version 7.8 result of <tt>PrintText {~} = X{'    ':unspace}X</tt> is:
   '    ':unspace = XX
   '    ':unspace = XX


===Examples===                                                                                 
==Examples==
                                                                                                  
                                                                                                  
The following are example Unspace statements:                                                     
The following are example Unspace statements:                                                     

Revision as of 05:14, 19 January 2011

Remove whitespace characters from the string (String class)


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.

Syntax

%outString = string:Unspace[( [Spaces= string], [Leading= boolean], - [Trailing= boolean], [Compress= boolean])]

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.
  • Prior to Version 7.8 of the Sirius Mods, Unspace compressed a string consisting entirely of whitespace characters to a single whitespace character. As of version 7.8 (and also in version 7.7 maintenance), Unspace converts a string of whitespace characters to a null string. The version 7.8 result of PrintText {~} = X{' ':unspace}X is:
  '    ':unspace = XX

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

See also

List of intrinsic String methods