Class fever.utils.StringUtil

Description

Provides some string utilities methods.

Field Index

EMPTY_CHARS

Method Index

areEqual(), contains(), finishWithChar(), insertAt(), isEndingWith(), isStartingWith(), isWhiteSpace(), leftTrim(), multiply(), remove(), removeAt(), replace(), replaceAt(), reverse(), rightTrim(), substitute(), substituteByArray(), trim(), uppercaseFirst(), uppercaseWords()

Field Detail

EMPTY_CHARS

static public EMPTY_CHARS:String
Defines default empty characters values

Method Detail

replace

static public function replace(source:String, search:String, replaceWith:String):String

Replaces all occurencies of the passed-in string search with the passed-in string replaceWith in the passed-in string source.

Parameters

sourcestring source
searchstring to replace
replaceWithstring to insert

replaceAt

static public function replaceAt(source:String, index:Number, replaceWith:String):String

Replaced character defined at index position in source string with passed-in replaceWith substring.

Parameters

sourceString to parse
indexPosition
replaceWithString to insert

insertAt

static public function insertAt(source:String, index:Number, insert:String):String

Inserts passed-in insert string at index position in source string.

Parameters

sourceString to parse
indexPosition
insertString to insert in source string

remove

static public function remove(source:String, toRemove:String):String

Removes passed-in remvove substring from source string.

Parameters

sourceString to parse

removeAt

static public function removeAt(source:String, index:Number):String

Removes character at passed-in index position.

Parameters

sourceString to parse
indexPosition

reverse

static public function reverse(source:String):String

Reverses the passed-in source string.

Parameters

sourcesource string

trim

static public function trim(source:String, chars:String):String

Removes all empty characters, defined in EMPTY_CHARS property, at the beginning and end of the passed-in source string.

Parameters

sourceSource string
chars(optional) Character list to trim. ( default use EMPTY_CHARS )

leftTrim

static public function leftTrim(source:String, chars:String):String

Removes all empty characters, defined in EMPTY_CHARS property, at the beginning of the passed-in source string.

Parameters

sourceSource string
chars(optional) Character list to trim. ( default use EMPTY_CHARS )

rightTrim

static public function rightTrim(source:String, chars:String):String

Removes all empty characters, defined in EMPTY_CHARS property, at the end of the passed-in source string.

Parameters

sourceSource string
chars(optional) Character list to trim. ( default use EMPTY_CHARS )

isStartingWith

static public function isStartingWith(source:String, search:String):Boolean

Returns true if passed-in source starts with passed-in search string.

Parameters

sourcestring to evaluate
searchsearch string

isEndingWith

static public function isEndingWith(source:String, search:String):Boolean

Returns true if passed-in source ends with passed-in search string.

Parameters

sourcestring to evaluate
searchsearch string

contains

static public function contains(source:String, search:String):Boolean

Returns true if passed-in search string is contained on passed-in source one.

areEqual

static public function areEqual(source1:String, source2:String, caseSensitive:Boolean):Boolean

Returns true is 2 passed string are equals.

Use passed-in caseSensitive argument to use case sensitive test.

Parameters

source1First string
source2Second string to compare
caseSensitive(optional) true to enable case sensitive test, otherwise false

isWhiteSpace

static public function isWhiteSpace(char:String):Boolean

Returns true if the specified string is a single space, tab, return, or newline character.

Parameters

char String to test

substitute

static public function substitute(source:String):String

Substitutes "{n}" tokens within the specified string with their respective arguments passed in.

Parameters

source String to parse
...arguments to use for substitution.

substituteByArray

static public function substituteByArray(source:String, array:Array):String

Substitutes "{n}" tokens within the specified string with passed-in args array content.

Parameters

source String to parse
arrayContent to use for substitution.

uppercaseFirst

static public function uppercaseFirst(source:String):String

Capitalizes the first letter of passed-in source string.

uppercaseWords

static public function uppercaseWords(source:String):String

Capitalizes the first character of every word in the passed-in source.

multiply

static public function multiply(source:String, n:Number):String

Multiply passed-in source n times.

finishWithChar

static public function finishWithChar(source:String, end:String, check:Boolean):String

Forces the passed-in source to finish with end sub string.

Use check parameter to 'rightTrim' the source before.