mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-06 10:53:42 +00:00
Add a trim function to CPString.
This commit is contained in:
@@ -62,7 +62,8 @@ var CPStringRegexSpecialCharacters = [
|
||||
'/', '.', '*', '+', '?', '|', '$', '^',
|
||||
'(', ')', '[', ']', '{', '}', '\\'
|
||||
],
|
||||
CPStringRegexEscapeExpression = new RegExp("(\\" + CPStringRegexSpecialCharacters.join("|\\") + ")", 'g');
|
||||
CPStringRegexEscapeExpression = new RegExp("(\\" + CPStringRegexSpecialCharacters.join("|\\") + ")", 'g'),
|
||||
CPStringRegexTrimWhitespace = new RegExp("(^\\s+|\\s+$)", 'g');
|
||||
|
||||
/*!
|
||||
@class CPString
|
||||
@@ -421,6 +422,13 @@ var CPStringRegexSpecialCharacters = [
|
||||
return '' + substring(0, range.location) + replacement + substring(range.location + range.length, self.length);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a new string with leading and trailing whitespace trimmed
|
||||
*/
|
||||
- (CPString)stringByTrimmingWhitespace
|
||||
{
|
||||
return self.replace(CPStringRegexTrimWhitespace, "");
|
||||
}
|
||||
|
||||
// Identifying and comparing strings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user