Public Constants
 ConstantDefined By
  camelCase : Function
Converts a hyphenated string to a camelcased string.
core.strings
  capitalize : Function
Converts the first letter of each word in a string to uppercase.
core.strings
  center : Function
Returns the center string representation of the specified string value.
core.strings
  clean : Function
Removes all extraneous whitespace from a string and trims it.
core.strings
  compare : Function
Compares two strings.
core.strings
  endsWith : Function
Determines wether the end of a string matches the specified value.
core.strings
  fastformat : Function
Quick and fast format of a string using indexed parameters only.
core.strings
  format : Function
Format a string using indexed or named parameters.
core.strings
  hyphenate : Function
Converts a camelcased string to a hyphenated string.
core.strings
  indexOfAny : Function
Reports the index of the first occurrence in this instance of any character in a specified array of Unicode characters.
core.strings
  insert : Function
Inserts a specified instance of String at a specified index position in this instance.
core.strings
  lastIndexOfAny : Function
Reports the index position of the last occurrence in this instance of one or more characters specified in a Unicode array.
core.strings
  lineTerminatorChars : Array
Like white space characters, line terminator characters are used to improve source text readability and to separate tokens (indivisible lexical units) from each other.
core.strings
  pad : Function
Apply character padding to a string.
core.strings
  padLeft : Function
Right-aligns the characters in this instance, padding on the left with a specified Unicode character for a specified total length.
core.strings
  padRight : Function
Left-aligns the characters in this string, padding on the right with a specified Unicode character, for a specified total length.
core.strings
  repeat : Function
Returns a new String value who contains the specified String characters repeated count times.
core.strings
  startsWith : Function
Checks if this string starts with the specified prefix.
core.strings
  trim : Function
Removes all occurrences of a set of specified characters (or strings) from the beginning and end of this instance.
core.strings
  trimEnd : Function
Removes all occurrences of a set of characters specified in an array from the end of this instance.
core.strings
  trimStart : Function
Removes all occurrences of a set of characters specified in an array from the beginning of this instance.
core.strings
  userAgent : Function
Returns a user-agent string.
core.strings
  whiteSpaceChars : Array
Contains all white space chars.
core.strings
Constant Detail
camelCaseConstant
public const camelCase:Function

Converts a hyphenated string to a camelcased string.

Example :

     import core.strings.camelCase ;
     trace( camelCase("hello-world" ) ) ; // helloWorld
     

capitalizeConstant 
public const capitalize:Function

Converts the first letter of each word in a string to uppercase.

Example :

     import core.strings.capitalize ;
     trace( capitalize( "hello world" ) ) ; // Hello World
     

centerConstant 
public const center:Function

Returns the center string representation of the specified string value.

Example :

     import core.strings.center ;
     
     trace( center("hello world", 0) )         ; // hello world
     trace( center("hello world", 20) )        ; //     hello world     
     trace( center("hello world", 20, "_" ) )  ; // ____hello world_____
     

cleanConstant 
public const clean:Function

Removes all extraneous whitespace from a string and trims it.

Example :

     import core.strings.clean ;
     trace( clean("   hello world \n\n" ) ) ; // hello world
     

compareConstant 
public const compare:Function

Compares two strings.

The default comparaison algorithm use an ascending alphabetic order with minuscule weighting less than majuscule.

return :

basic usage

     
     var s0:String = "HELLO";
     var s1:String = "hello";
     var s2:String = "welcome";
     var s3:String = "world";
     
     trace( compare( s1, s2 ) ); //-1
     trace( compare( s2, s1 ) ); //1
     trace( compare( s1, s3 ) ); //1
     trace( compare( s1, s1 ) ); //0
     trace( compare( s1, s0 ) ); //0
     trace( compare( s1, s0, true ) ); //-1
     trace( compare( s0, s1, true ) ); //1
     
     

endsWithConstant 
public const endsWith:Function

Determines wether the end of a string matches the specified value.


Example
basic usage
     
     import core.strings.endsWith ;
     
     trace( endsWith( "hello world", "world" ) ); //true
     trace( endsWith( "hello world", "hello" ) ); //false
     
     trace( endsWith( "hello.txt" , "txt" ) ) ; // true
     
     
fastformatConstant 
public const fastformat:Function

Quick and fast format of a string using indexed parameters only.

Usage :

See also


Example
basic usage
     
     import core.strings.fastformat;
     
     trace( fastformat( "hello {0}", "world" ) );
     //output: "hello world"
     
     trace( fastformat( "hello {0} {1} {2}", [ "the", "big", "world" ] ) );
     //output: "hello the big world"
     
     
formatConstant 
public const format:Function

Format a string using indexed or named parameters.

Usage :


Throws
Error — When a token is malformed.

See also


Example
Basic example
     
     import core.strings.format ;
     
     trace( format( "{0},{1},{2}" , "apples" , "oranges", "grapes" ) ) ; // apples,oranges,grapes
     trace( format( "{0},{1},{2}" , ["apples" , "oranges", "grapes"] ) ) ; // apples,oranges,grapes
     trace( format( "{path}{0}{name}{1}" , { name : "format" , path:"core.strings" } , "." , "()" ) ) ; // core.strings.format()
     
     
hyphenateConstant 
public const hyphenate:Function

Converts a camelcased string to a hyphenated string.


Example
     
     import core.strings.hyphenate ;
     trace( hyphenate( "helloWorld" ) ) ; //"hello-world"
     
     
indexOfAnyConstant 
public const indexOfAny:Function

Reports the index of the first occurrence in this instance of any character in a specified array of Unicode characters.


Example
     
     import core.strings.indexOfAny ;
     
     var result:int ;
     
     result = indexOfAny("hello world", [2, "hello", 5]) ;
     trace( result ) ; // 0
     
     result = indexOfAny("Five = 5", [2, "hello", 5]) ;
     trace( result ) ; // 2
     
     result = indexOfAny("actionscript is good", [2, "hello", 5]) ; 
     trace( result ) ; // -1
     
     
insertConstant 
public const insert:Function

Inserts a specified instance of String at a specified index position in this instance.

note :

if index is null, we directly append the value to the end of the string. if index is zero, we directly insert it to the begining of the string.

Example :

     import core.strings.insert ;
     
     var result:String;
     
     result = insert("hello", 0, "a" );  // ahello
     trace(result) ;
     
     result = insert("hello", -1, "a" ); // hellao
     trace(result) ;
     
     result = insert("hello", 10, "a" ); // helloa
     trace(result) ;
     
     result = insert("hello", 1, "a" );  // haello
     trace(result) ;
     

lastIndexOfAnyConstant 
public const lastIndexOfAny:Function

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

Example :

 
     import core.strings.lastIndexOfAny ;
     trace( lastIndexOfAny("hello world", ["2", "hello", "5"]) ); // 0
     trace( lastIndexOfAny("Five 5 = 5 and not 2" , ["2", "hello", "5"]) ); // 19
     trace( lastIndexOfAny("Five 5 = 5 and not 2" , ["5", "hello", "2"]) ); // 9
     trace( lastIndexOfAny("Five 5 = 5 and not 2" , ["5", "hello", "2"] , 8) ); // 5
     trace( lastIndexOfAny("Five 5 = 5 and not 2" , ["5", "hello", "2"] , 8 , 3) ); // -1
     


Throws
ArgumentError — if the anyOf argument is 'null' or 'undefined'.
lineTerminatorCharsConstant 
public const lineTerminatorChars:Array

Like white space characters, line terminator characters are used to improve source text readability and to separate tokens (indivisible lexical units) from each other. However, unlike white space characters, line terminators have some influence over the behaviour of the syntactic grammar. In general, line terminators may occur between any two tokens, but there are a few places where they are forbidden by the syntactic grammar. A line terminator cannot occur within any token, not even a string. Line terminators also affect the process of automatic semicolon insertion.

ECMAScript specification.

padLeftConstant 
public const padLeft:Function

Right-aligns the characters in this instance, padding on the left with a specified Unicode character for a specified total length.

Example :

     import core.strings.padLeft ;
     
     trace( padLeft("hello", 8) ) ; //  "   hello"
     trace( padLeft("hello", 8, ".") ); //  "...hello" 
     

padRightConstant 
public const padRight:Function

Left-aligns the characters in this string, padding on the right with a specified Unicode character, for a specified total length.

Example :

     import core.strings.padRight ;
     trace( padRight("hello", 8) ) ; //  "hello   "
     trace( padRight("hello", 8, ".") ); //  "hello..." 
     

padConstant 
public const pad:Function

Apply character padding to a string.

The padding amount is relative to the string length, if you try to pad the string "hello" (5 chars) with an amount of 10, you will not add 10 spacing chars to the original string, but you will obtain " hello", exactly 10 chars after the padding.

A positive amount value will pad the string on the left (right align), and a negative amount value will pad the string on the right (left align),


Example
basic usage
     
     import core.strings.pad;
     
     var word:String = "hello";
     
     trace( "[" + pad( word, 8 ) + "]" ); //align to the right
     trace( "[" + pad( word, -8 ) + "]" ); //align to the left
     
     //output
     //[   hello]
     //[hello   ]
     
     
padding a list of names
     
     import core.strings.pad;
     
     var seinfeld:Array = [ "jerry", "george", "kramer", "helen" ];
     var len:uint       = seinfeld.length ;
     for( var i:uint ; i<len ; i++ )
     {
         trace( pad( seinfeld[i] , 10 , "." ) ) ;
     }
     
     //output
     //.....jerry
     //....george
     //....kramer
     //.....helen
     
     
repeatConstant 
public const repeat:Function

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

Example :

     import core.strings.repeat ;
     
     trace( repeat( "hello" , 0 ) ) ; // hello
     trace( repeat( "hello" , 3 ) ) ; // hellohellohello
     

startsWithConstant 
public const startsWith:Function

Checks if this string starts with the specified prefix.

Example :

     import core.strings.startsWith ;
     
     var file:String = "hello.txt";
     
     trace( startsWith( file , "hello" ) ) ; // true
     

trimEndConstant 
public const trimEnd:Function

Removes all occurrences of a set of characters specified in an array from the end of this instance.

Example :

     import core.strings.trimEnd ;
     import core.strings.whiteSpaceChars ;
     trace( trimEnd("---hello world---" , ["-"].concat( whiteSpaceChars) ) ); // ---hello world
     

trimStartConstant 
public const trimStart:Function

Removes all occurrences of a set of characters specified in an array from the beginning of this instance.

Example :

     import core.strings.trimStart ;
     import core.strings.whiteSpaceChars ;
     
     trace( trimStart("---hello world---" , ["-"].concat(whiteSpaceChars) ) ); // hello world---
     

trimConstant 
public const trim:Function

Removes all occurrences of a set of specified characters (or strings) from the beginning and end of this instance.

Example :

     import core.strings.trim ;
     trace( trim("\r\t   hello world   \t ") ); // hello world
     

userAgentConstant 
public const userAgent:Function

Returns a user-agent string.

based on:

here some examples:

     - URLRequestDefaults (only if an AIR app and with compatible option set to true)
       "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/526.9+ (KHTML, like Gecko) AdobeAIR/1.5"
       "Mozilla/5.0 (Windows; U; en) AppleWebKit/526.9+ (KHTML, like Gecko) AdobeAIR/1.5"
       "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/526.9+ (KHTML, like Gecko) AdobeAIR/1.5"
     - userAgent
       "Tamarin/1.0 cyclone (Macintosh; StandAlone; Mac OS 10.6.7; en; DEBUG) AdobeFlashPlayer/10.0.32.18"
       "Tamarin/1.0 cyclone (Macintosh; StandAlone; Mac OS 10.6.7; en; DEBUG) AdobeFlashPlayer/10.0.32.18 MyApp/2.0"
       "Tamarin/1.0 cyclone (Macintosh; StandAlone; Mac OS 10.6.7; en; DEBUG) MyApp/2.0"
       "Tamarin/1.0 cyclone (Macintosh; StandAlone; DEBUG) AdobeFlashPlayer/10.0.32.18"
       "Mozilla/5.0 (Macintosh; StandAlone; Mac OS 10.6.7; en; DEBUG) AdobeFlashPlayer/10.0.32.18"
       "Mozilla/5.0 (Macintosh; StandAlone; DEBUG) AdobeFlashPlayer/10.0.32.18"
     

note:

By default we consider our "product" to be Tamarin, it will work for Flash Player, AIR and RedTamarin.

ex: "Tamarin/1.0 cyclone (Macintosh; ..."

By default if you don't provide an apptoken, it will deduced automatically (eg. "AdobeAIR/1.5" , "AdobeFlashPlayer/9.0.124.0", etc.)

ex: "... Mac OS 10.6.7; en) AdobeFlashPlayer/10.0.32.18"

By default, self application description and application token accumulates

ex: "... Mac OS 10.6.7; en) AdobeFlashPlayer/10.0.32.18 MyApp/2.0"

if you use the `noself` option you can remove the self application description

ex: "... Mac OS 10.6.7; en) MyApp/2.0"

whiteSpaceCharsConstant 
public const whiteSpaceChars:Array

Contains all white space chars.

Note :

Function detail