Contains useful static function for performing operations on Strings.
public static function capitalize(s:String):String
Returns a version of the supplied string with the first letter capitalized.
Parameters
Returns
public static function compare(s1:String, s2:String):int
Compares two String values, returning -1, 0, or 1. Case-sensitive.
Parameters
Returns
public static function compareIgnoreCase(s1:String, s2:String):int
Compares two String values, returning -1, 0, or 1. Not case-sensitive.
Parameters
Returns
public static function deNull(str:String):String
Return the specified String, or "" if it is null.
Parameters
Returns
public static function endsWith(str:String, substr:String):Boolean
Does the specified string end with the specified substring.
Parameters
Returns
public static function formatNumber(n:Number):String
Format the specified number, nicely, with commas.
TODO: format specifyer, locale handling, etc. We'll probably move this into a
NumberFormat-style class.
Parameters
Returns
public static function fromBytes(bytes:ByteArray):String
Turn the specified byte array, containing only ascii characters, into a String.
Parameters
Returns
public static function hashCode(str:String):int
Get a hashCode for the specified String. null returns 0.
This hashes identically to Java's String.hashCode(). This behavior has been useful
in various situations.
Parameters
Returns
public static function hexdump(bytes:ByteArray):String
Create line-by-line hexadecimal output with a counter, much like the
'hexdump' Unix utility. For debugging purposes.
Parameters
Returns
public static function hexlate(bytes:ByteArray):String
Generates a string from the supplied bytes that is the hex encoded
representation of those byts. Returns the empty String for a
null
or empty byte array.
Parameters
Returns
public static function isBlank(str:String):Boolean
Is the specified string null, empty, or does it contain only whitespace?
Parameters
Returns
public static function isLowerCase(str:String):Boolean
Return true iff the first character is a lower-case character.
Parameters
Returns
public static function isUpperCase(str:String):Boolean
Return true iff the first character is an upper-case character.
Parameters
Returns
public static function isWhitespace(character:String):Boolean
Parameters
Returns
| Boolean — true if the specified String is == to a single whitespace character.
|
public static function pad(str:String, length:int, padChar:String = " "):String
Append 0 or more copies of the padChar String to the input String
until it is at least the specified length.
Parameters
| str:String |
|
| length:int |
|
| padChar:String (default = " ")
|
Returns
public static function parseBoolean(str:String):Boolean
Parse a Boolean from a String, throwing an ArgumentError if the String
contains invalid characters.
"1", "0", and any capitalization variation of "true" and "false" are
the only valid input values.
Parameters
| str:String — the String to parse.
|
Returns
protected static function parseInt0(str:String, radix:uint, allowNegative:Boolean):Number
Internal helper function for parseInteger and parseUnsignedInteger.
Parameters
| str:String |
|
| radix:uint |
|
| allowNegative:Boolean |
Returns
public static function parseInteger(str:String, radix:uint = 0):int
Parse an integer more anally than the built-in parseInt() function,
throwing an ArgumentError if there are any invalid characters.
The built-in parseInt() will ignore trailing non-integer characters.
Parameters
| str:String — The string to parse.
|
|
| radix:uint (default = 0 ) — The radix to use, from 2 to 16. If not specified the radix will be 10,
unless the String begins with "0x" in which case it will be 16,
or the String begins with "0" in which case it will be 8.
|
Returns
public static function parseNumber(str:String):Number
Parse a Number from a String, throwing an ArgumentError if there are any
invalid characters.
1.5, 2e-3, -Infinity, Infinity, and NaN are all valid Strings.
Parameters
| str:String — the String to parse.
|
Returns
public static function parseUnsignedInteger(str:String, radix:uint = 0):uint
Parse an integer more anally than the built-in parseInt() function,
throwing an ArgumentError if there are any invalid characters.
The built-in parseInt() will ignore trailing non-integer characters.
Parameters
| str:String — The string to parse.
|
|
| radix:uint (default = 0 ) — The radix to use, from 2 to 16. If not specified the radix will be 10,
unless the String begins with "0x" in which case it will be 16,
or the String begins with "0" in which case it will be 8.
|
Returns
public static function parseURLs(s:String):Array
Locate URLs in a string, return an array in which even elements
are plain text, odd elements are urls (as Strings). Any even element
may be an empty string.
Parameters
Returns
public static function prepad(str:String, length:int, padChar:String = " "):String
Prepend 0 or more copies of the padChar String to the input String
until it is at least the specified length.
Parameters
| str:String |
|
| length:int |
|
| padChar:String (default = " ")
|
Returns
public static function simpleToString(obj:Object, fieldNames:Array = null):String
Return a pretty basic toString of the supplied Object.
Parameters
| obj:Object — the object to be string'd
|
|
| fieldNames:Array (default = null ) — the names of fields to print, or null to print all public variables.
|
Returns
public static function startsWith(str:String, substr:String):Boolean
Does the specified string start with the specified substring.
Parameters
Returns
public static function substitute(str:String, ... args):String
Substitute "{n}" tokens for the corresponding passed-in arguments.
Parameters
Returns
public static function toBytes(s:String):ByteArray
Turn the specified String, containing only ascii characters, into a ByteArray.
Parameters
Returns
public static function toColorString(c:uint, prefix:String = "0x"):String
Format the specified uint as a String color value, for example "0x000000".
Parameters
| c:uint — the uint value to format.
|
|
| prefix:String (default = "0x ") — the prefix to place in front of it. |
Returns
public static function toHex(n:uint, width:uint):String
Return a hexadecimal representation of an unsigned int, potentially left-padded with
zeroes to arrive at of precisely the requested width, e.g.
toHex(131, 4) -> "0083"
Parameters
Returns
public static function toString(obj:*, refs:Dictionary = null):String
Nicely format the specified object into a String.
Parameters
| obj:* |
|
| refs:Dictionary (default = null )
|
Returns
public static function trim(str:String):String
Utility function that strips whitespace from the beginning and end of a String.
Parameters
Returns
public static function trimBeginning(str:String):String
Utility function that strips whitespace from the beginning of a String.
Parameters
Returns
public static function trimEnd(str:String):String
Utility function that strips whitespace from the end of a String.
Parameters
Returns
public static function truncate(s:String, maxLength:int, append:String = ""):String
Truncate the specified String if it is longer than maxLength.
The string will be truncated at a position such that it is
maxLength chars long after the addition of the 'append' String.
Parameters
| s:String — a String to add to the truncated String only after
truncation.
|
|
| maxLength:int |
|
| append:String (default = " ")
|
Returns
public static function unhexlate(hex:String):ByteArray
Turn a hexlated String back into a ByteArray.
Parameters
Returns
protected static function validateDecimal(str:String, allowDot:Boolean, allowTrailingE:Boolean):String
Internal helper function for parseNumber.
Parameters
| str:String |
|
| allowDot:Boolean |
|
| allowTrailingE:Boolean |
Returns
protected static const DECIMAL:Array
Decimal digits.
protected static const HEX:Array
Hexidecimal digits.
protected static const URL_REGEXP:RegExp
A regular expression that finds URLs.
Copyright © 2007-2009 Three Rings Design, Inc.