MODULES Uize.Str.Trim
1. Introduction
The Uize.Str.Trim
module provides methods for detecting and removing whitespace padding around single line strings.
DEVELOPERS: Chris van Rensburg
1.1. Examples
There are no dedicated showcase example pages for the Uize.Str.Trim
module.
SEARCH FOR EXAMPLES
Use the link below to search for example pages on the UIZE Web site that reference the Uize.Str.Trim
module...
SEARCH
1.2. Implementation Info
The Uize.Str.Trim
module defines the Uize.Str.Trim
package under the Uize.Str
namespace.
1.2.1. Features Introduced in This Module
The features listed in this section have been introduced in this module.
STATIC METHODS
Uize.Str.Trim.hasPadding
| Uize.Str.Trim.trim
| Uize.Str.Trim.trimLeft
| Uize.Str.Trim.trimRight
STATIC PROPERTIES
1.2.2. Features Overridden in This Module
No features have been overridden in this module.
1.2.3. Features Inherited From Other Modules
This module has no inherited features.
1.2.4. Modules Directly Under This Namespace
There are no modules directly under this namespace.
1.2.5. Unit Tests
The Uize.Str.Trim
module is unit tested by the Uize.Test.Uize.Str.Trim
test module.
2. Static Methods
2.1. Uize.Str.Trim.hasPadding
Returns a boolean, indicidating whether or not the specified string has whitespace padding on either - or both - of its sides (i.e. leading or trailing whitespace).
SYNTAX
hasPaddingBOOL = Uize.Str.Trim.hasPadding (sourceSTR);
EXAMPLES
Uize.Str.Trim.hasPadding (' leading whitespace'); // returns true Uize.Str.Trim.hasPadding ('trailing whitespace '); // returns true Uize.Str.Trim.hasPadding (' leading and trailing whitespace '); // returns true Uize.Str.Trim.hasPadding ('no padding'); // returns false Uize.Str.Trim.hasPadding (' '); // returns true Uize.Str.Trim.hasPadding (''); // returns false
NOTES
see the related Uize.Str.Trim.trim static method |
IMPLEMENTATION INFO
this feature was introduced in this module |
2.2. Uize.Str.Trim.trim
Returns a string, that is the specified source string minus any whitespace padding to the left and right of the first and last non-whitespace characters, respectively.
SYNTAX
trimmedSTR = Uize.Str.Trim.trim (sourceSTR);
EXAMPLES
Uize.Str.Trim.trim (' THIS IS A STRING '); // returns 'THIS IS A STRING' Uize.Str.Trim.trim ('\tTHIS IS A STRING\t'); // returns 'THIS IS A STRING' Uize.Str.Trim.trim ('\n\nTHIS IS A STRING\n\n'); // returns 'THIS IS A STRING' Uize.Str.Trim.trim (' \t \n\n \t'); // returns ''
2.2.1. Working with Multi-line Strings
This method regards linebreak characters as whitespace.
Therefore, this method cannot be used to trim whitespace padding on a line by line basis. To trim line by line, use the Uize.Str.Trim.Lines.trim
method implemented in the Uize.Str.Trim.Lines
module that is dedicated to working with multi-line strings.
NOTES
see the companion Uize.Str.Trim.trimLeft and Uize.Str.Trim.trimRight static methods |
|
see the related Uize.Str.Trim.hasPadding static method |
IMPLEMENTATION INFO
this feature was introduced in this module |
2.3. Uize.Str.Trim.trimLeft
Returns a string, that is the specified source string minus any whitespace padding to the left of the first non-whitespace character or the end of the string (i.e. leading whitespace).
SYNTAX
leftTrimmedSTR = Uize.Str.Trim.trimLeft (sourceSTR);
EXAMPLES
Uize.Str.Trim.trim (' THIS IS A STRING '); // returns 'THIS IS A STRING ' Uize.Str.Trim.trim ('\tTHIS IS A STRING\t'); // returns 'THIS IS A STRING\t' Uize.Str.Trim.trim ('\n\nTHIS IS A STRING\n\n'); // returns 'THIS IS A STRING\n\n' Uize.Str.Trim.trim (' \t \n\n \t'); // returns ''
2.3.1. Working with Multi-line Strings
This method regards linebreak characters as whitespace.
Therefore, this method cannot be used to trim whitespace padding on a line by line basis. To left trim line by line, use the Uize.Str.Trim.Lines.trimLeft
method implemented in the Uize.Str.Trim.Lines
module that is dedicated to working with multi-line strings.
NOTES
see the companion Uize.Str.Trim.trim and Uize.Str.Trim.trimRight static methods |
IMPLEMENTATION INFO
this feature was introduced in this module |
2.4. Uize.Str.Trim.trimRight
Returns a string, that is the specified source string minus any whitespace padding to the right of the last non-whitespace character or the start of the string (i.e. trailing whitespace).
SYNTAX
rightTrimmedSTR = Uize.Str.Trim.trimRight (sourceSTR);
EXAMPLES
Uize.Str.Trim.trim (' THIS IS A STRING '); // returns ' THIS IS A STRING' Uize.Str.Trim.trim ('\tTHIS IS A STRING\t'); // returns '\tTHIS IS A STRING' Uize.Str.Trim.trim ('\n\nTHIS IS A STRING\n\n'); // returns '\n\nTHIS IS A STRING' Uize.Str.Trim.trim (' \t \n\n \t'); // returns ''
2.4.1. Working with Multi-line Strings
This method regards linebreak characters as whitespace.
Therefore, this method cannot be used to trim whitespace padding on a line by line basis. To right trim line by line, use the Uize.Str.Trim.Lines.trimRight
method implemented in the Uize.Str.Trim.Lines
module that is dedicated to working with multi-line strings.
NOTES
see the companion Uize.Str.Trim.trim and Uize.Str.Trim.trimLeft static methods |
IMPLEMENTATION INFO
this feature was introduced in this module |