Packagemx.utils
Classpublic class StringUtil
InheritanceStringUtil Inheritance Object

The StringUtil utility class is an all-static class with methods for working with String objects within Flex. You do not create instances of StringUtil; instead you call methods such as the StringUtil.substitute() method.



Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined by
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
[static] Returns true if the specified string is a single space, tab, carriage return, newline, or formfeed character.
StringUtil
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
[static] Substitutes "{n}" tokens within the specified string with the respective arguments passed in.
StringUtil
 Inherited
Returns the string representation of the specified object.
Object
  
[static] Removes all whitespace characters from the beginning and end of the specified string.
StringUtil
 Inherited
Returns the primitive value of the specified object.
Object
Method detail
isWhitespace()method
public static function isWhitespace(character:String):Boolean

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

Parameters
character:String — The String that is is being queried.

Returns
Booleantrue if the specified string is a single space, tab, carriage return, newline, or formfeed character.
substitute()method 
public static function substitute(str:String, ... rest):String

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

Parameters
str:String — The string to make substitutions 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 — Additional parameters that can be substituted in the str parameter at each {n} location, where n is an integer (zero based) index value into the array of values specified. If the first parameter is an array this array will be used as a parameter list. This allows reuse of this routine in other methods that want to use the ... rest signature. For example
      public function myTracer(str:String, ... rest):void
      { 
          label.text += StringUtil.substitute(str, rest) + "\n";
      } 

Returns
String — New string with all of the {n} tokens replaced with the respective arguments specified.

Example
var str:String = "here is some info '{0}' and {1}"; trace(StringUtil.substitute(str, 15.4, true)); // this will output the following string: // "here is some info '15.4' and true"

trim()method 
public static function trim(str:String):String

Removes all whitespace characters from the beginning and end of the specified string.

Parameters
str:String — The String whose whitespace should be trimmed.

Returns
String — Updated String where whitespace was removed from the beginning and end.




 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/langref/mx/utils/StringUtil.html