String Class Reference
[ECMAScript/QtScript - Native Objects]

ECMAScript String type. More...

Inheritance diagram for String:

Object List of all members.

Properties

Number length

Methods (DAZ Script 2 Extensions)

String arg (Number value, Number fieldWidth=0)
String arg (String value, Number fieldWidth=0)
String argDec (Number value, Number fieldWidth=0, Number format= 'g', Number precision)
String argInt (Number value, Number fieldWidth=0, Number base=10)
Boolean endsWith (RegExp pattern)
Boolean endsWith (String pattern)
Number find (RegExp pattern, Number startPos=0)
Number find (String pattern, Number startPos=0)
Number findRev (RegExp pattern, Number startPos=length-1)
Number findRev (String pattern, Number startPos=length-1)
Boolean isEmpty ()
String left (Number num)
String lower ()
String mid (Number startIndex, Number num)
String right (Number num)
Number searchRev (RegExp pattern)
Number searchRev (String pattern)
Boolean startsWith (RegExp pattern)
Boolean startsWith (String pattern)
String upper ()

Methods (ECMAScript)

String charAt (Number pos)
Number charCodeAt (Number pos)
String concat (string1[,...])
Number indexOf (RegExp pattern, Number startPos=0)
Number indexOf (String pattern, Number startPos=0)
Number lastIndexOf (RegExp pattern, Number startPos=length-1)
Number lastIndexOf (String pattern, Number startPos=length-1)
Number localeCompare (String that)
String match (RegExp pattern)
String replace (RegExp pattern, String newValue)
Number search (RegExp pattern)
Number search (String pattern)
String slice (Number start, Number end)
Array split (RegExp pattern)
Array split (String pattern)
Array split (RegExp separator, Number limit)
Array split (RegExp separator, Number limit)
Array split (String separator, Number limit)
Array split (String separator)
String substring (Number startIndex, Number num)
String toLocaleLowerCase ()
String toLocaleUpperCase ()
String toLowerCase ()
String toString ()
String toUpperCase ()
String valueOf ()
static String fromCharCode (Number charCode1[,...])

Constructors

 String (String text)
 String ()

Detailed Description

ECMAScript String type.

This is the DAZ Script counterpart of the QString type used in the DAZ Studio SDK.

A String is a sequence of zero or more Unicode characters. All string indexes are zero-based, which means the index for the last character in the string str is always str.length - 1.

Example:
Strings creation and concatenation
    var str1 = "foo";
    var str2 = new String( "foo" );
    var str3 = str1 + " " + str2;
    var str4 = String( "%1%2" ).arg( "foo" ).arg( "bar" );


Constructor & Destructor Documentation

String::String (  ) 

Default constructor.

String::String ( String  text  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
text - The initial value of the string


Member Function Documentation

String String::arg ( Number  value,
Number  fieldWidth = 0 
)

Parameters:
value - The Number to represent as a string.
fieldWidth - Specifies the minimum amount of space that value is padded to. A positive fieldWidth will produce right aligned text, a negative fieldWidth will produce left aligned text.
Returns:
The modified string, replacing the lowest occurrance of %1, %2,... with value.

String String::arg ( String  value,
Number  fieldWidth = 0 
)

Parameters:
value - The text to represent as a string.
fieldWidth - Specifies the minimum amount of space that value is padded to. A positive fieldWidth will produce right aligned text, a negative fieldWidth will produce left aligned text.
Returns:
The modified string, replacing the lowest occurrance of %1, %2,... with value.

String String::argDec ( Number  value,
Number  fieldWidth = 0,
Number  format = 'g',
Number  precision 
)

Specialized for cases where value is a decimal.

Parameters:
value - The Number to represent as a string.
fieldWidth - Specifies the minimum amount of space that value is padded to. A positive fieldWidth will produce right aligned text, a negative fieldWidth will produce left aligned text.
format - The format to use:
  • 'e' : format as [-]9.9e[+|-]999
  • 'E' : format as [-]9.9E[+|-]999
  • 'f' : format as [-]9.9
  • 'g' : use 'e' or 'f' format, whichever is more concise
  • 'G' : use 'E' or 'f' format, whichever is more concise
precision - With 'e', 'E' and 'f', this is the numbers of digits after the decimal point. With 'g' and 'G', this is the maximum number of significant digits.
Returns:
The modified string, replacing the lowest occurrance of %1, %2,... with value.
Example:
        var fValue = Math.PI;
        var sValue = String( "%1" ).argDec( fValue, 0, 'f', 5 );
        
        MessageBox.information( String( "Variable : sValue\nType : %1\nValue : %2" ).arg( typeof sValue ).arg( sValue ),
            "String.argDec(...)", "&OK" );

String String::argInt ( Number  value,
Number  fieldWidth = 0,
Number  base = 10 
)

Specialized for cases where value is an integer.

Parameters:
value - The Number to represent as a string.
fieldWidth - Specifies the minimum amount of space that value is padded to. A positive fieldWidth will produce right aligned text, a negative fieldWidth will produce left aligned text.
base - The base, which must be between 2 and 36
Returns:
The modified string, replacing the lowest occurrance of %1, %2,... with value.
Example:
        var nValue = 32;
        var sValue = String( "%1" ).argInt( nValue, 0, 10 );
        
        MessageBox.information( String( "Variable : sValue\nType : %1\nValue : %2" ).arg( typeof sValue ).arg( sValue ),
            "String.argInt(...)", "&OK" );

String String::charAt ( Number  pos  ) 

Parameters:
pos The index position to retrieve the character from.
Returns:
The character in the string at pos . If pos is out of bounds, undefined is returned.

Number String::charCodeAt ( Number  pos  ) 

Parameters:
pos The index position of the character to retrieve the code for.
Returns:
The character code of the character at pos . If pos is out of bounds, undefined is returned.

String String::concat ( string1  [,...]  ) 

Parameters:
string1 The first string to concatenate.
Returns:
This string with the given string(s) concatenated. Essentially, this + string1 + ... + stringN.

Boolean String::endsWith ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
If the string ends with pattern, returns true. Otherwise returns false.

Boolean String::endsWith ( String  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
If the string ends with pattern, returns true. Otherwise returns false.

Number String::find ( RegExp  pattern,
Number  startPos = 0 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of the first occurrence of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Number String::find ( String  pattern,
Number  startPos = 0 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of the first occurrence of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Number String::findRev ( RegExp  pattern,
Number  startPos = length-1 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of the first occurrence of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the end of the string. If the pattern is not found in the string, -1 is returned.

Number String::findRev ( String  pattern,
Number  startPos = length-1 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of the first occurrence of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the end of the string. If the pattern is not found in the string, -1 is returned.

static String String::fromCharCode ( Number  charCode1[,...]  )  [static]

Parameters:
charCode1 The first character of the string
Returns:
A string comprised of the characters represented by the Unicode character codes in the argument(s).

Number String::indexOf ( RegExp  pattern,
Number  startPos = 0 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Number String::indexOf ( String  pattern,
Number  startPos = 0 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The [zero-based] index at the beginning of the first occurrence of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Boolean String::isEmpty (  ) 

Returns:
True if the string is empty (has a length of 0), otherwise false.

Number String::lastIndexOf ( RegExp  pattern,
Number  startPos = length-1 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the end of the string. If the pattern is not found in the string, -1 is returned.

Number String::lastIndexOf ( String  pattern,
Number  startPos = length-1 
)

Parameters:
pattern The pattern to search the string for
startPos The [zero-based] index to begin the search at.
Returns:
The index of pattern in the string, starting at position startPos. If startPos is not specified, the function starts at the end of the string. If the pattern is not found in the string, -1 is returned.

String String::left ( Number  num  ) 

Parameters:
num The number of characters to copy from the beginning of the string
Returns:
The substring of this string containing the num leftmost characters.

Number String::localeCompare ( String  that  ) 

Performs a locale-sensitive comparison of the given string with this string.

Parameters:
that The string to compare this string to.
Returns:
A numeric value that will be negative, zero or positive depending on whether this comes before that, or that comes before this, zero is returned if the strings match.

String String::lower (  ) 

Returns:
The string, with all characters converted to lower case.
See also:
toLowerCase()

String String::match ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
The matched pattern in the string. If the pattern is not found in the string, undefined is returned.

String String::mid ( Number  startIndex,
Number  num 
)

Parameters:
startIndex The index of the first character to copy from the string
num The number of characters to copy from the string
Returns:
The substring of this string starting at startIndex including num characters.
See also:
substring()

String String::replace ( RegExp  pattern,
String  newValue 
)

Parameters:
pattern The pattern to search the string for
newValue The new string to replace matches with
Returns:
The modified string, replacing first occurrence of pattern in the string with newValue if pattern is found in the string.

String String::right ( Number  num  ) 

Parameters:
num The number of characters to copy from the end of the string
Returns:
The substring of this string containing the num rightmost characters.

Number String::search ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
The index of the first occurrence of pattern in the string, starting at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Number String::search ( String  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
The index of the first occurrence of pattern in the string, starting at the beginning of the string. If the pattern is not found in the string, -1 is returned.

Number String::searchRev ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
The index of the first occurrence of pattern in the string, starting at the end of the string. If the pattern is not found in the string, -1 is returned.

Number String::searchRev ( String  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
The index of the first occurrence of pattern in the string, starting at the end of the string. If the pattern is not found in the string, -1 is returned.

String String::slice ( Number  start,
Number  end 
)

Creates a substring from this string, starting with the character at index start, and going to, but not including the character at index end.

Parameters:
start The index of the first character in the string to include in the substring. If negative, it will be treated as this.length + start.
end The index of the character at the end of the substring, this character will not be included in the substring. If undefined, the substring will include all characters from start to the end of this string. If negative, it will be treated as this.length + end.
Returns:
The substring that was created.

Array String::split ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
An array of strings made up of this string split on each occurrence of pattern.

Array String::split ( String  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
An array of strings made up of this string split on each occurrence of pattern.

Array String::split ( RegExp  separator,
Number  limit 
)

Splits this string into an array of substrings at each occurrence of separator.

Parameters:
separator A regular expression containing the separator that will be searched for. If an empty expression is given, the result will contain one entry for each character in this string. If undefined is given the result will contain one entry containing the whole string.
limit If the resulting array contains more entries than limit, it will be truncated to contain limit entries.
Returns:
An array of substrings.

Array String::split ( RegExp  separator,
Number  limit 
)

Splits this string into an array of substrings at each occurrence of separator.

Parameters:
separator A regular expression containing the separator that will be searched for. If an empty expression is given, the result will contain one entry for each character in this string. If undefined is given the result will contain one entry containing the whole string.
Returns:
An array of substrings.

Array String::split ( String  separator,
Number  limit 
)

Splits this string into an array of substrings at each occurrence of separator.

Parameters:
separator A string containing the separator that will be searched for. If an empty string is given, the result will contain one entry for each character in this string. If undefined is given the result will contain one entry containing the whole string.
limit If the resulting array contains more entries than limit, it will be truncated to contain limit entries.
Returns:
An array of substrings.

Array String::split ( String  separator  ) 

Splits this string into an array of substrings at each occurrence of separator.

Parameters:
separator A string containing the separator that will be searched for. If an empty string is given, the result will contain one entry for each character in this string. If undefined is given the result will contain one entry containing the whole string.
Returns:
An array of substrings.

Boolean String::startsWith ( RegExp  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
If the string starts with pattern, returns true. Otherwise returns false.

Boolean String::startsWith ( String  pattern  ) 

Parameters:
pattern The pattern to search the string for
Returns:
If the string starts with pattern, returns true. Otherwise returns false.

String String::substring ( Number  startIndex,
Number  num 
)

Parameters:
startIndex The index of the first character to copy to the substring
num The number of characters to copy into the substring
Returns:
The substring of this string starting at startIndex including num characters.
See also:
mid()

String String::toLocaleLowerCase (  ) 

Provides a locale-aware version of String::toLowerCase().

Returns:
This string converted to lower case in a locale-specific manner.

String String::toLocaleUpperCase (  ) 

Provides a locale-aware version of String::toUpperCase().

Returns:
This string converted to upper case in a locale-specific manner.

String String::toLowerCase (  ) 

Returns:
The string, with all characters converted to lower case.
See also:
lower()

String String::toString (  ) 

Returns:
This string object.

Reimplemented from Object.

String String::toUpperCase (  ) 

Returns:
The string, with all characters converted to upper case.
See also:
upper()

String String::upper (  ) 

Returns:
The string, with all characters converted to upper case.
See also:
toUpperCase()

String String::valueOf (  ) 

Returns:
This string object.

Reimplemented from Object.


Member Data Documentation

Number String::length

The length of the string.


Generated on Thu Sep 24 12:21:16 2009

Copyright © 2002 - 2009 DAZ 3D, Inc.