Packageorg.springextensions.actionscript.utils
Classpublic class StringUtils

Contains utility methods for working with strings.



Public Methods
 MethodDefined by
  
addAt(string:String, value:int, position:*):String
[static] Adds/inserts a new string at a certain position in the source string.
StringUtils
  
fixNewlines(string:String):String
[static] Fixes double newlines in a text.
StringUtils
  
hasText(string:String):Boolean
[static] Checks if the given string has actual text.
StringUtils
  
isDigit(a:String):Boolean
[static] Returns if the given character is a digit or not.
StringUtils
  
isWhitespace(a:String):Boolean
[static] Returns if the given character is a white space or not.
StringUtils
  
leftTrim(string:String):String
[static] Removes all empty characters at the beginning of a string.
StringUtils
  
leftTrimForChar(string:String, char:String):String
[static] Removes all characters at the beginning of the {
StringUtils
  
leftTrimForChars(string:String, chars:String):String
[static] Removes all characters at the beginning of the {
StringUtils
  
naturalCompare(a:String, b:String, caseSensitive:Boolean = false):int
[static] Natural sort order compare function.
StringUtils
  
nthIndexOf(haystack:String, n:uint, needle:String, startIndex:Number = 0):int
[static] Extended String::indexOf
StringUtils
  
removeAt(string:String, beginIndex:int, endIndex:int):String
[static] Removes a part of the text between 2 positions.
StringUtils
  
replaceAt(string:String, value:int, beginIndex:int, endIndex:*):String
[static] Replaces a part of the text between 2 positions.
StringUtils
  
rightTrim(string:String):String
[static] Removes all empty characters at the end of a string.
StringUtils
  
rightTrimForChar(string:String, char:String):String
[static] Removes all characters at the end of the {
StringUtils
  
rightTrimForChars(string:String, chars:String):String
[static] Removes all characters at the end of the {
StringUtils
  
tokenizeToArray(string:String, delimiters:String):Array
[static] Tokenizes a string to an array using the given delimiters.
StringUtils
  
trim(string:String):String
[static] Removes all empty characters at the beginning and at the end of the passed-in {
StringUtils
Method detail
addAt()method
public static function addAt(string:String, value:int, position:*):String

Adds/inserts a new string at a certain position in the source string.

Parameters
string:String
 
value:int
 
position:*

Returns
String
fixNewlines()method 
public static function fixNewlines(string:String):String

Fixes double newlines in a text.

Parameters
string:String

Returns
String
hasText()method 
public static function hasText(string:String):Boolean

Checks if the given string has actual text.

Parameters
string:String

Returns
Boolean
isDigit()method 
public static function isDigit(a:String):Boolean

Returns if the given character is a digit or not.

Parameters
a:String

Returns
Boolean
isWhitespace()method 
public static function isWhitespace(a:String):Boolean

Returns if the given character is a white space or not.

Parameters
a:String

Returns
Boolean
leftTrim()method 
public static function leftTrim(string:String):String

Removes all empty characters at the beginning of a string.

Characters that are removed: spaces {Parameters

string:String — the string to trim

Returns
String — the trimmed string
leftTrimForChar()method 
public static function leftTrimForChar(string:String, char:String):String

Removes all characters at the beginning of the {

Parameters
string:String — the string to trim
 
char:String — the character to remove

Returns
String — the trimmed string

Throws
— if you try to remove more than one character
leftTrimForChars()method 
public static function leftTrimForChars(string:String, chars:String):String

Removes all characters at the beginning of the {

Parameters
string:String — the string to trim
 
chars:String — the characters to remove from the beginning of the {

Returns
String — the trimmed string
naturalCompare()method 
public static function naturalCompare(a:String, b:String, caseSensitive:Boolean = false):int

Natural sort order compare function.

Parameters
a:String
 
b:String
 
caseSensitive:Boolean (default = false)

Returns
int
nthIndexOf()method 
public static function nthIndexOf(haystack:String, n:uint, needle:String, startIndex:Number = 0):int

Extended String::indexOf

Parameters
haystack:String — string to search in
 
n:uint — which ocurance of needle
 
needle:String — The substring for which to search
 
startIndex:Number (default = 0) — An optional integer specifying the starting index of the search.

Returns
int
removeAt()method 
public static function removeAt(string:String, beginIndex:int, endIndex:int):String

Removes a part of the text between 2 positions.

Parameters
string:String
 
beginIndex:int
 
endIndex:int

Returns
String
replaceAt()method 
public static function replaceAt(string:String, value:int, beginIndex:int, endIndex:*):String

Replaces a part of the text between 2 positions.

Parameters
string:String
 
value:int
 
beginIndex:int
 
endIndex:*

Returns
String
rightTrim()method 
public static function rightTrim(string:String):String

Removes all empty characters at the end of a string.

Characters that are removed: spaces {Parameters

string:String — the string to trim

Returns
String — the trimmed string
rightTrimForChar()method 
public static function rightTrimForChar(string:String, char:String):String

Removes all characters at the end of the {

Parameters
string:String — the string to trim
 
char:String — the character to remove

Returns
String — the trimmed string

Throws
— if you try to remove more than one character
rightTrimForChars()method 
public static function rightTrimForChars(string:String, chars:String):String

Removes all characters at the end of the {

Parameters
string:String — the string to trim
 
chars:String — the characters to remove from the end of the {

Returns
String — the trimmed string
tokenizeToArray()method 
public static function tokenizeToArray(string:String, delimiters:String):Array

Tokenizes a string to an array using the given delimiters.

Parameters
string:String
 
delimiters:String

Returns
Array
trim()method 
public static function trim(string:String):String

Removes all empty characters at the beginning and at the end of the passed-in {

Parameters
string:String — the string to trim

Returns
String — the trimmed string