Packagevegas.util
Classpublic class StringUtil

The StringUtil utility class is an extended String class with methods for working with string. This class complete the system.Strings static class.



Public Methods
 MethodDefined by
  
clone(s:String):String
[static] Returns a shallow copy of the specified string.
StringUtil
  
copy(str:String):String
[static] Returns a copy by value of this object.
StringUtil
  
firstChar(str:String):String
[static] Determines whether the start of this instance matches the specified String.
StringUtil
  
isEmpty(str:String):Boolean
[static] Returns true if this string is empty.
StringUtil
  
lastChar(str:String):String
[static] Returns the last char of the string.
StringUtil
  
lastIndexOfAny(str:String, ar:Array):int
[static] Reports the index position of the last occurrence in this instance of one or more characters specified in a Unicode array.
StringUtil
  
repeat(str:String = "", count:uint = 0):String
[static] Returns a new String value who contains the specified String characters repeated count times.
StringUtil
  
replace(str:String, search:String, replace:String):String
[static] Replaces the 'search' string with the 'replace' String.
StringUtil
  
reverse(str:String):String
[static] Reverses the current instance.
StringUtil
  
splice(str:String, startIndex:uint, deleteCount:uint = 0, value:* = null):String
[static] Adds and removes elements in the string.
StringUtil
  
toArray(str:String, separator:String = ""):Array
[static] Returns an array representation of this instance.
StringUtil
  
toSource(str:String, ... rest):String
[static] Returns the eden representation of the object.
StringUtil
  
ucFirst(str:String):String
[static] Returns the value of this specified string with the first character in uppercase.
StringUtil
  
ucWords(str:String):String
[static] Uppercases the first character of each word in a string.
StringUtil
Public Constants
 ConstantDefined by
  EMPTY : String = ""
[static] Represents the empty string.
StringUtil
  SPC : String = " "
[static] Represents the space string value.
StringUtil
Method detail
clone()method
public static function clone(s:String):String

Returns a shallow copy of the specified string.

Parameters
s:String

Returns
String — a shallow copy of the specified string.
copy()method 
public static function copy(str:String):String

Returns a copy by value of this object.

Parameters
str:String

Returns
String — a copy by value of this object.
firstChar()method 
public static function firstChar(str:String):String

Determines whether the start of this instance matches the specified String.

Parameters
str:String

Returns
String
isEmpty()method 
public static function isEmpty(str:String):Boolean

Returns true if this string is empty.

Example :

   import vegas.util.StringUtil ;
   var b1:Boolean = StringUtil.isEmpty("") ; // true
   var b2:Boolean = StringUtil.isEmpty("hello world") ; // false
   
Parameters
str:String — the string object.

Returns
Booleantrue if this string is empty.
lastChar()method 
public static function lastChar(str:String):String

Returns the last char of the string.

Example :

   import vegas.util.StringUtil ;
   trace( StringUtil.lastChar("hello world") ; // d
   
Parameters
str:String — the string object.

Returns
String — the last char of the string.
lastIndexOfAny()method 
public static function lastIndexOfAny(str:String, ar:Array):int

Reports the index position of the last occurrence in this instance of one or more characters specified in a Unicode array.

Parameters
str:String
 
ar:Array

Returns
int — the index position of the last occurrence in this instance of one or more characters specified in a Unicode array.
repeat()method 
public static function repeat(str:String = "", count:uint = 0):String

Returns a new String value who contains the specified String characters repeated count times.

Example :

         import vegas.util.StringUtil ;
         
         trace(StringUtil.repeat("hello", 0)) ; // hello
         trace(StringUtil.repeat("hello", 3)) ; // hellohellohello
         
Parameters
str:String (default = "")
 
count:uint (default = 0)

Returns
String — a new String value who contains the specified String characters repeated count times.
replace()method 
public static function replace(str:String, search:String, replace:String):String

Replaces the 'search' string with the 'replace' String.

Example :

   vegas.util.StringUtil.replace("hello world", "hello", "hi") ; // "hello world" -> "hi world"
   
Parameters
str:String — string to transform.
 
search:String
 
replace:String

Returns
String — the new string transform with this method.
reverse()method 
public static function reverse(str:String):String

Reverses the current instance.

Example :

   var reverse:String = vegas.util.StringUtil.reverse("hello") ; // "olleh"
   
Parameters
str:String

Returns
String — the reverse string of the specified string passed-in argument.
splice()method 
public static function splice(str:String, startIndex:uint, deleteCount:uint = 0, value:* = null):String

Adds and removes elements in the string.

Parameters
str:String — Index at which to start changing the string.
 
startIndex:uint — Indicating the number of old character elements to remove.
 
deleteCount:uint (default = 0) — The elements to add to the string. If you don't specify any elements, splice simply removes elements from the string.
 
value:* (default = null)

Returns
String

Example
   import vegas.util.StringUtil ;
   
   var result:String ;
   
   result = StringUtil.splice("hello world", 0, 1, "H") ;
   trace(result) ; // Hello world
   
   result = StringUtil.splice("hello world", 6, 0, "life") ;
   trace(result) ; // hello lifeworld
   
   result = StringUtil.splice("hello world", 6, 5, "life") ;
   trace(result) ; // hello life
   

toArray()method 
public static function toArray(str:String, separator:String = ""):Array

Returns an array representation of this instance.

Example :

   import vegas.util.StringUtil ;
   trace( StringUtil.toArray("hello world" )) ; // h,e,l,l,o, ,w,o,r,l,d
   
Parameters
str:String
 
separator:String (default = "")

Returns
Array — an array representation of this instance.
toSource()method 
public static function toSource(str:String, ... rest):String

Returns the eden representation of the object.

Parameters
str:String
 
... rest

Returns
String — a string representing the source code of the object.

Example
   import vegas.util.StringUtil ;
   var source:String = StringUtil.toSource("hello world") ;
    trace(source) ; // "hello world"
   

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

Returns the value of this specified string with the first character in uppercase.

Example :

   import vegas.util.StringUtil ;
   trace( StringUtil.ucFirst("hello world" )) ; // Hello world
   
Parameters
str:String

Returns
String — the value of this string with the first character in uppercase.
ucWords()method 
public static function ucWords(str:String):String

Uppercases the first character of each word in a string.

Example :

   import vegas.util.StringUtil ;
    trace( StringUtil.ucWords("hello world" )) ; // Hello World
   
Parameters
str:String

Returns
String — the string value with the first character in uppercase of each word in a string.
Constant detail
EMPTYconstant
public static const EMPTY:String = ""

Represents the empty string. This property should be read-only.

SPCconstant 
public static const SPC:String = " "

Represents the space string value.