String utilities class
Various string utilities
support
public static function argbToHex(n:Number):String
Converts an argb color to hex string
Parameters
| n:Number — The number to convert
|
Returns
| String — The formatted string
|
public static function csvToArray(str:String, preserve:Boolean = true):Array
Convert a simple CSV row string to an array
Does not handle quoted strings with embedded comma's, use parseCSV instead
Parameters
| str:String — to be processed
|
| |
| preserve:Boolean (default = true) — if true preserves any whitespace otherwise it strips all whitespace
|
Returns
public static function ellipsis(str:String, maxlen:int):String
Formats a string to use ellipsis (...) if it exceeds maxlen
Parameters
| str:String — The string to be formatted
|
| |
| maxlen:int — The maximum visble length of the string required
|
Returns
public static function escapeHTML(str:String):String
Escape HTML string
Parameters
| str:String — to be processed
|
Returns
public static function formatMessage(sections:*, ... rest):String
Substitutes "{n}" tokens within the array of specified message sections and returns the concatenated string.
Parameters
| sections:* — An array of optional message sections to make subsitutions in.
This string sections can contain special tokens of the form {n}, where n is a zero based index, that will be replaced with the additional parameters found at that index if specified.
If all the values for a section are all null that section will be dropped from the final message string.
|
| |
| ... rest — Optional array of values to be substituted
|
Returns
| String — New string with all of the {n} tokens replaced with the respective arguments specified.
|
public static function formatNationalPhoneNumber(p:String):String
Formats an national phone number (123) 456 4444
Parameters
| p:String — The phone number to format
|
Returns
| String — The formatted phone number
|
public static function formatPercent(r:Number, dp:int):String
Formats a number as percentage
For example (.50, 2) will be returned as 50.00%
Parameters
| r:Number — ratio a decimal value between 0 and 1
|
| |
| dp:int — decimal places
|
Returns
| String — the formatted value
|
public static function formatPhoneNumber(p:String):String
Formats an international phone number +999 123 456 4444
Parameters
| p:String — The phone number to format
|
Returns
| String — The formatted phone number
|
public static function insertCharAt(str:String, char:String, i:int):String
Insert text into a string at a given position
Parameters
| str:String — The string to be processed
|
| |
| char:String — The character or string to be inserted
|
| |
| i:int — The index of the location to insert at
|
Returns
public static function isDigit(ch:String):Boolean
Determines if the character is a digit
Parameters
| ch:String — Character to be processed
|
Returns
| Boolean — True if the charactre is a digit
|
public static function isSpace(ch:String):Boolean
Determines if the character is a space character
Parameters
| ch:String — Character to be processed
|
Returns
| Boolean — True if the charactre is a digit
|
public static function normalize(str:String):String
Normalize whitespace in a string
Parameters
| str:String — to be processed
|
Returns
public static function parseCSVRecordset(data:String, firstRowHeader:Boolean = false, columns:Array = null, reverse:Boolean = false):Array
Converts a CSV string to array of record objects.
Handles quoted and non-quoted strings and embed commas
Parameters
| data:String — The csv string to be parsed
|
| |
| firstRowHeader:Boolean (default = false) — If true it is assumed the first row in the recordset contains the namees of the columns
|
| |
| columns:Array (default = null) — If true the recordset is reversed.
|
| |
| reverse:Boolean (default = false) |
Returns
public static function parseCSVString(data:String):Array
Converts a CSV string to a simple array of strings
Handles quoted and non-quoted strings and embed commas
Parameters
Returns
public static function removeCharAt(str:String, start:int, end:int):String
Remove a single or a series of characters starting at a given location in a string
Parameters
| str:String — The string to be processed
|
| |
| start:int — The index of the location to remove at
|
| |
| end:int — The ending index of the location to remove. If not specified a single character is removed.
|
Returns
public static function repeatStr(str:String, repeat:int):String
Returns a string containing a number of repetitions of str
Parameters
Returns
| String — str concat repeat number of times
|
public static function replace(str:String, findStr:String, replaceStr:String = ""):String
Replace text in a string with other text
Parameters
| str:String — The string to be processed
|
| |
| findStr:String — What to find in str
|
| |
| replaceStr:String (default = "") — The text to replace findStr
|
Returns
public static function replaceCharAt(str:String, char:String, start:int, end:int):String
Replace a single or a series of character starting at a given location in a string
Parameters
| str:String — The string to be processed
|
| |
| char:String — The new character or string to be used
|
| |
| start:int — The index of the location to replace at
|
| |
| end:int — The ending index of the location to replace. If not specified a single character is replaced.
|
Returns
public static function rgbToHex(n:Number):String
Converts an rgb color to hex string
Parameters
| n:Number — The number to convert
|
Returns
| String — The formatted string
|
public static function strip(str:String, findStr:String):String
Strps all instance of findStr from a string
Parameters
| str:String — to be processed
|
| |
| findStr:String |
Returns
public static function stripChars(str:String, chars:Array):String
strip specified chars from a string
Parameters
Returns
public static function stripSpace(str:String):String
Strip space from a string
Parameters
| str:String — to be processed
|
Returns
public static function substitute(message:String, ... rest):String
Substitutes "{n}" tokens within the specified string with their respective arguments passed in.
Parameters
| message:String — The string to make subsitutions in.
This string can contain special tokens of the form {n}, where n is a zero based index, that will be replaced with the additional parameters found at that index if specified.
|
| |
| ... rest — Optional array of values to be substituted
|
Returns
| String — New string with all of the {n} tokens replaced with the respective arguments specified.
|
public static function trim(str:String, c:String):String
Left and Right Trims a string of whitespace
Parameters
| str:String — The string to be trimmed
|
| |
| c:String — The character to trim by default it is the whitespace
|
Returns
public static function trimLeft(str:String, c:String):String
Left Trims a string of whitespace
Parameters
| str:String — The string to be trimmed
|
| |
| c:String — The character to trim by default it is the whitespace
|
Returns
public static function trimRight(str:String, c:String):String
Right Trims a string of whitespace
Parameters
| str:String — The string to be trimmed
|
| |
| c:String — The character to trim by default it is the whitespace
|
Returns
public static function unescapeHTML(str:String):String
Unescape HTML string
Parameters
| str:String — to be processed
|
Returns
public static function zeroPad(num:Number, digits:int, trailing:Boolean):String
zero pads a string
Parameters
| num:Number — - the number to pad
|
| |
| digits:int — - the number of digits to pad to
& |
| |
| trailing:Boolean — - controls whether the padding is prefixed or suffixed
|
Returns
| String — The formatted string
|