Class String
TopLevel
Class String
Object
String
The String object represents any sequence of zero or more characters that are to be treated strictly as text.
Properties
length  :  Number
The length of the String object.
Constructor Summary
String()
Constructs the String.
String(num : Number)
Constructs the String from the specified Number object.
String(str : String)
Constructs a new String from the specified String object.
Method Summary
charAt(index : Number) : String
Returns a string containing the character at position index.
charCodeAt(index : Number) : Number
Returns the UTF-16 code unit at the given position index.
codePointAt(index : Number) : Number
Returns the Unicode code point at the given position index.
concat(strings : String...) : String
Returns a new String created by concatenating the string arguments together.
endsWith(searchString : String) : boolean
Tests if this string ends with a given string.
endsWith(searchString : String, length : Number) : boolean
Tests if this string ends with a given string.
equals(obj : Object) : boolean
Returns true if this string is equal to the string representation of the passed objects.
equalsIgnoreCase(obj : Object) : boolean
Returns true if this string is equal to the string representation of the passed objects.
static fromCharCode(c : Number...) : String
Returns a new String from one or more UTF-16 code units.
static fromCodePoint(c : Number...) : String
Returns a new String from one or more characters with Unicode code points.
includes(substring : String) : boolean
Returns if substring is contained in this String object.
includes(substring : String, start : Number) : boolean
Returns if substring is contained in this String object.
indexOf(substring : String) : Number
Returns the index of substring in this String object.
indexOf(substring : String, start : Number) : Number
Returns the index of substring in this String object using the specified start value as the location to begin searching.
lastIndexOf(substring : String) : Number
Returns the last index of substring in this String object.
lastIndexOf(substring : String, start : Number) : Number
Returns the last index of substring in this String object, using the specified start position as the location from which to begin the search.
localeCompare(other : String) : Number
Returns a number indicating whether the current String sorts before, the same as, or after the parameter other, based on browser and system-dependent string localization.
match(regexp : RegExp) : String[]
Returns an array of strings that match the regular expression regexp.
normalize() : String
Returns the normalized form of this Unicode string.
normalize(form : String) : String
Returns the normalized form of this Unicode string according to the standard as described in https://unicode.org/reports/tr15/.
padEnd(targetLength : Number) : String
Appends space characters to the current string to ensure the resulting string reaches the given target length.
padEnd(targetLength : Number, fillString : String) : String
Appends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
padStart(targetLength : Number) : String
Prepends space characters to the current string to ensure the resulting string reaches the given target length.
padStart(targetLength : Number, fillString : String) : String
Prepends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
static raw(callSite : Object, substitutions : String...) : String
The static String.raw() method is a tag function of template literals.
repeat(count : Number) : String
Returns a new string repeating this string the given number of times.
replace(regexp : RegExp, replacement : String) : String
Returns a new String that results when matches of the regexp parameter are replaced by the replacement parameter.
replace(regexp : RegExp, function : Function) : String
Returns a new String that results when matches of the regexp parameter are replaced by using the specified function.
replace(literal : String, replacement : String) : String
Returns a new String that results when matches of the literal parameter are replaced by the replacement parameter.
replace(literal : String, replacement : String, flags : String) : String
Returns a new String that results when matches of the literal parameter are replaced by the replacement parameter.
replace(literal : String, function : Function) : String
Returns a new String that results when matches of the literal parameter are replaced by using the specified function.
replace(literal : String, function : Function, flags : String) : String
Returns a new String that results when matches of the literal parameter are replaced by using the specified function.
search(regexp : RegExp) : Number
Searches for a match between the passed regular expression and this string and returns the zero-based index of the match, or -1 if no match is found.
slice(start : Number, end : Number) : String
Returns a substring of the current String where the specified start and end locations are used to delimit the String.
split(delimiter : String) : String[]
Returns an array of String instances created by splitting the current String based on the delimiter.
split(regexp : RegExp) : String[]
Returns an array of String instances created by splitting the current String based on the regular expression.
split(delimiter : String, limit : Number) : String[]
Returns an array of String instances created by splitting the current String based on the delimiter and limited in size by the limit parameter.
split(regexp : RegExp, limit : Number) : String[]
Returns an array of String instances created by splitting the current String based on the regular expression and limited in size by the limit parameter.
startsWith(searchString : String) : boolean
Tests if this string starts with a given string.
startsWith(searchString : String, position : Number) : boolean
Tests if this string starts with a given string.
substr(start : Number) : String
Creates and returns a new String by splitting the current string at the specified start location until the end of the String.
substr(start : Number, length : Number) : String
Creates and returns a new String by splitting the current string at the specified start location and limited by the length value.
substring(from : Number) : String
Creates and returns a new String by splitting the current string at the specified from location until the end of the String.
substring(from : Number, to : Number) : String
Creates and returns a new String by splitting the current string at the specified from location until the specified to location.
toLocaleLowerCase() : String
Returns a copy of the current string in all lower-case letters.
toLocaleUpperCase() : String
Returns a copy of the current string in all upper-case letters.
toLowerCase() : String
Returns a copy of the current string in all lower-case letters.
toString() : String
Returns a String value of this object.
toUpperCase() : String
Returns a copy of the current string in all upper-case letters.
trim() : String
Removes white space characters at the start and the end of the string.
trimEnd() : String
Removes white space characters at the end of the string.
trimLeft() : String
Removes white space characters at the start of the string.
trimRight() : String
Removes white space characters at the end of the string.
trimStart() : String
Removes white space characters at the start of the string.
valueOf() : String
Returns a String value of this object.
Constructor Detail
String
public String()
Constructs the String.

String
public String(num : Number)
Constructs the String from the specified Number object.
Parameters:
num - the number that will be converted to a String.

String
public String(str : String)
Constructs a new String from the specified String object.
Parameters:
str - the String that will be converted to a new String.

Method Detail
charAt
charAt(index : Number) : String
Returns a string containing the character at position index. You should use this method instead of substring when you need only a single character.
Parameters:
index - the index at which the character string is located.
Returns:
a string containing the character at position index.

charCodeAt
charCodeAt(index : Number) : Number
Returns the UTF-16 code unit at the given position index. If the position is invalid NaN is returned.
Parameters:
index - The index of the code unit within the string.
Returns:
a non-negative integer representing a UTF-16 code unit or NaN if the index is not valid.

codePointAt
codePointAt(index : Number) : Number
Returns the Unicode code point at the given position index. The index is a position within the string in UTF-16 encoding. If the index points to the begin of a surrogate pair the only the code unit at the position is returned. If the index is invalid undefined is returned.
API Versioned:
From version 21.2.
Parameters:
index - The index of the starting code unit within the string.
Returns:
The Unicode code point, an UTF-16 code unit or undefined.

concat
concat(strings : String...) : String
Returns a new String created by concatenating the string arguments together.
Parameters:
strings - zero, one, or more String arguments
Returns:
a new String created by concatenating the string arguments together.

endsWith
endsWith(searchString : String) : boolean
Tests if this string ends with a given string.
API Versioned:
From version 21.2.
Parameters:
searchString - The characters to be searched for this string.
Returns:
true if the search string was found else false

endsWith
endsWith(searchString : String, length : Number) : boolean
Tests if this string ends with a given string.
API Versioned:
From version 21.2.
Parameters:
searchString - The characters to be searched for this string.
length - Assumes this string has only this given length.
Returns:
true if the search string was found else false

equals
equals(obj : Object) : boolean
Returns true if this string is equal to the string representation of the passed objects.
Parameters:
obj - another object, typically another string

equalsIgnoreCase
equalsIgnoreCase(obj : Object) : boolean
Returns true if this string is equal to the string representation of the passed objects. The comparison is done case insensitive.
Parameters:
obj - another object, typically another string

fromCharCode
static fromCharCode(c : Number...) : String
Returns a new String from one or more UTF-16 code units.
Parameters:
c - zero, one, or more UTF-16 code units.

fromCodePoint
static fromCodePoint(c : Number...) : String
Returns a new String from one or more characters with Unicode code points.
API Versioned:
From version 21.2.
Parameters:
c - zero, one, or more code points.

includes
includes(substring : String) : boolean
Returns if substring is contained in this String object.
API Versioned:
From version 21.2.
Parameters:
substring - the String to search for in this String.
Returns:
true if substring occurs within the current string, else false.

includes
includes(substring : String, start : Number) : boolean
Returns if substring is contained in this String object.
API Versioned:
From version 21.2.
Parameters:
substring - the String to search for in this String.
start - the location in the String from which to begin the search.
Returns:
true if substring occurs within the current string, else false.

indexOf
indexOf(substring : String) : Number
Returns the index of substring in this String object. If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
Returns:
the index of substring or -1.

indexOf
indexOf(substring : String, start : Number) : Number
Returns the index of substring in this String object using the specified start value as the location to begin searching. If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
start - the location in the String from which to begin the search.
Returns:
the index of substring or -1.

lastIndexOf
lastIndexOf(substring : String) : Number
Returns the last index of substring in this String object. If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
Returns:
the last index of substring or -1.

lastIndexOf
lastIndexOf(substring : String, start : Number) : Number
Returns the last index of substring in this String object, using the specified start position as the location from which to begin the search. If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
start - the location from which to begin the search.
Returns:
the last index of substring or -1.

localeCompare
localeCompare(other : String) : Number
Returns a number indicating whether the current String sorts before, the same as, or after the parameter other, based on browser and system-dependent string localization.
Parameters:
other - the String to compare against this String.
Returns:
a number indicating whether the current String sorts before, the same as, or after the parameter other.

match
match(regexp : RegExp) : String[]
Returns an array of strings that match the regular expression regexp.
Parameters:
regexp - the regular expression to use.
Returns:
an array of strings that match the regular expression.

normalize
normalize() : String
Returns the normalized form of this Unicode string. Same as calling normalize(String) with parameter 'NFC'.
API Versioned:
From version 21.2.
Returns:
The normalized form of this Unicode string.

normalize
normalize(form : String) : String
Returns the normalized form of this Unicode string according to the standard as described in https://unicode.org/reports/tr15/. In a normalized string, identical text is replaced by identical sequences of code points.
API Versioned:
From version 21.2.
Parameters:
form - The normalization variant to use. Must be one of 'NFC', 'NFD', 'NFKC', 'NFKD'.
Returns:
The normalized form of this Unicode string.

padEnd
padEnd(targetLength : Number) : String
Appends space characters to the current string to ensure the resulting string reaches the given target length.
API Versioned:
From version 21.2.
Parameters:
targetLength - The length to be reached.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength ending with space characters.

padEnd
padEnd(targetLength : Number, fillString : String) : String
Appends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
API Versioned:
From version 21.2.
Parameters:
targetLength - The length to be reached.
fillString - The string providing the characters to be used for filling.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength with the (possibly multiple times) added and truncated fillString.

padStart
padStart(targetLength : Number) : String
Prepends space characters to the current string to ensure the resulting string reaches the given target length.
API Versioned:
From version 21.2.
Parameters:
targetLength - The length to be reached.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength starting with space characters.

padStart
padStart(targetLength : Number, fillString : String) : String
Prepends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
API Versioned:
From version 21.2.
Parameters:
targetLength - The length to be reached.
fillString - The string providing the characters to be used for filling.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength with the (possibly multiple times) added and truncated fillString.

raw
static raw(callSite : Object, substitutions : String...) : String
The static String.raw() method is a tag function of template literals.

it can be used in different ways:

 String.raw`Hello\n${40+2}!`;
 // returns: Hello\n42!
 // \ is here not an escape character like in string literals

 String.raw({ raw: ['a', 'b', 'c'] }, '-', '.' );
 // returns: a-b.c
 
API Versioned:
From version 22.7.
Parameters:
callSite - A well-formed template call site object, like { raw: ['a', 'b', 'c'] }.
substitutions - The substitution values.
Returns:
A string constructed by the template with filled substitutions.

repeat
repeat(count : Number) : String
Returns a new string repeating this string the given number of times.
API Versioned:
From version 21.2.
Parameters:
count - The number of times this string should be repeated. Must be non-negative.
Returns:
A new string repeating this string the given number of times.

replace
replace(regexp : RegExp, replacement : String) : String
Returns a new String that results when matches of the regexp parameter are replaced by the replacement parameter. The original String is not modified so you must capture the new String in a variable to preserve changes. If regexp has the global flag set, all occurrences are replaced, if the global flag is not set only the first occurrence is replaced.
Parameters:
regexp - the regular expression to use.
replacement - a String that is to take the place of all matches of regexp in the current String.
Returns:
a new String that results when matches of the regexp parameter are replaced by the replacement.

replace
replace(regexp : RegExp, function : Function) : String
Returns a new String that results when matches of the regexp parameter are replaced by using the specified function. The original String is not modified so you must capture the new String in a variable to preserve changes. When you specify a function as the second parameter, the function is invoked after the match has been performed.
Parameters:
regexp - the regular expression to use.
function - a Function that operates on matches of regexp in the current String.
Returns:
a new String that results when matches of the regexp parameter are replaced by the function.

replace
replace(literal : String, replacement : String) : String
Returns a new String that results when matches of the literal parameter are replaced by the replacement parameter. The original String is not modified so you must capture the new String in a variable to preserve changes. This method only replaces the first occurrence of the literal. To replace all occurrences see the polymorphic method with a regular expression as argument.
Parameters:
literal - the literal string to locate.
replacement - a String that is to take the place of all matches of regexp in the current String.
Returns:
a new String that results when the first match of the literal parameter is replaced by the replacement parameter.

replace
replace(literal : String, replacement : String, flags : String) : String
Returns a new String that results when matches of the literal parameter are replaced by the replacement parameter. The original String is not modified so you must capture the new String in a variable to preserve changes. This method only replaces the first occurrence of the literal. To replace all occurrences see the polymorphic method with a regular expression as argument. Note that if flags
API Versioned:
No longer available as of version 21.2.
Deprecated:
Parameters:
literal - the literal string to locate.
replacement - a String that is to take the place of all matches of regexp in the current String.
flags - a String containing any combination of the Regular Expression flags of g - global match, i - ignore case, m - match over multiple lines.
Returns:
a new String that results when the first match of the literal parameter is replaced by the replacement parameter.

replace
replace(literal : String, function : Function) : String
Returns a new String that results when matches of the literal parameter are replaced by using the specified function. The original String is not modified so you must capture the new String in a variable to preserve changes. When you specify a function as the second parameter, the function is invoked after the match has been performed.
Parameters:
literal - the literal string to locate.
function - a Function that operates on the match of literal in the current String.
Returns:
a new String that results when the first match of the literal parameter is replaced by the specified function.

replace
replace(literal : String, function : Function, flags : String) : String
Returns a new String that results when matches of the literal parameter are replaced by using the specified function. The original String is not modified so you must capture the new String in a variable to preserve changes. When you specify a function as the second parameter, the function is invoked after the match has been performed.
API Versioned:
No longer available as of version 21.2.
Deprecated:
Parameters:
literal - the literal string to locate.
function - a Function that operates on the match of literal in the current String.
flags - a String containing any combination of the Regular Expression flags of g - global match, i - ignore case, m - match over multiple lines.
Returns:
a new String that results when the first match of the literal parameter is replaced by the specified function.

search
search(regexp : RegExp) : Number
Searches for a match between the passed regular expression and this string and returns the zero-based index of the match, or -1 if no match is found.
Parameters:
regexp - the regular expression to use.
Returns:
the zero-based indexed value of the first character in the current string that matches the pattern of the regular expression regexp, or -1 if no match is found.

slice
slice(start : Number, end : Number) : String
Returns a substring of the current String where the specified start and end locations are used to delimit the String.
Parameters:
start - the start position in the current String from which the slice will begin.
end - the end position in the current String from which the slice will terminate.
Returns:
the String between the start and end positions.

split
split(delimiter : String) : String[]
Returns an array of String instances created by splitting the current String based on the delimiter.
Parameters:
delimiter - the delimiter to use to split the string.
Returns:
an array of String instances created by splitting the current String based on the delimiter.

split
split(regexp : RegExp) : String[]
Returns an array of String instances created by splitting the current String based on the regular expression.
Parameters:
regexp - the regular expression to use to split the string.
Returns:
an array of String instances created by splitting the current String based on the regular expression.

split
split(delimiter : String, limit : Number) : String[]
Returns an array of String instances created by splitting the current String based on the delimiter and limited in size by the limit parameter.
Parameters:
delimiter - the delimiter to use to split the string.
limit - controls the maximum number of items that will be returned.
Returns:
an array of String instances created by splitting the current String based on the delimiter and limited in size by the limit parameter.

split
split(regexp : RegExp, limit : Number) : String[]
Returns an array of String instances created by splitting the current String based on the regular expression and limited in size by the limit parameter.
Parameters:
regexp - the regular expression to use to split the string.
limit - controls the maximum number of items that will be returned.
Returns:
an array of String instances created by splitting the current String based on the regular expression and limited in size by the limit parameter.

startsWith
startsWith(searchString : String) : boolean
Tests if this string starts with a given string.
API Versioned:
From version 21.2.
Parameters:
searchString - The characters to be searched for this string.
Returns:
true if the search string was found else false

startsWith
startsWith(searchString : String, position : Number) : boolean
Tests if this string starts with a given string.
API Versioned:
From version 21.2.
Parameters:
searchString - The characters to be searched for this string.
position - The position in this string at which to begin searching for searchString.
Returns:
true if the search string was found else false

substr
substr(start : Number) : String
Creates and returns a new String by splitting the current string at the specified start location until the end of the String.
Parameters:
start - the start position in the current string from which the new string will be created.
Returns:
a new String created by splitting the current string starting at the specified start location until the end of the String.

substr
substr(start : Number, length : Number) : String
Creates and returns a new String by splitting the current string at the specified start location and limited by the length value.
Parameters:
start - the start position in the current string from which the new string will be created.
length - controls the length of the new string.
Returns:
a new String created by splitting the current string starting at the specified start location and limited by the length value.

substring
substring(from : Number) : String
Creates and returns a new String by splitting the current string at the specified from location until the end of the String.
Parameters:
from - the start position in the current string from which the new string will be created.
Returns:
a new String created by splitting the current string starting at the specified from location until the end of the String.

substring
substring(from : Number, to : Number) : String
Creates and returns a new String by splitting the current string at the specified from location until the specified to location.
Parameters:
from - the start position in the current string from which the new string will be created.
to - the end position in the current string from which the new string will be created.
Returns:
a new String created by splitting the current string starting at the specified from location until the specified to location. value.

toLocaleLowerCase
toLocaleLowerCase() : String
Returns a copy of the current string in all lower-case letters.
Returns:
a copy of the current string in all lower-case letters.

toLocaleUpperCase
toLocaleUpperCase() : String
Returns a copy of the current string in all upper-case letters.
Returns:
a copy of the current string in all upper-case letters.

toLowerCase
toLowerCase() : String
Returns a copy of the current string in all lower-case letters.
Returns:
a copy of the current string in all lower-case letters.

toString
toString() : String
Returns a String value of this object.
Returns:
a String value of this object.

toUpperCase
toUpperCase() : String
Returns a copy of the current string in all upper-case letters.
Returns:
a copy of the current string in all upper-case letters.

trim
trim() : String
Removes white space characters at the start and the end of the string.
Returns:
A new string without leading and ending white space characters.

trimEnd
trimEnd() : String
Removes white space characters at the end of the string.
API Versioned:
From version 21.2.
Returns:
A new string without ending white space characters.

trimLeft
trimLeft() : String
Removes white space characters at the start of the string. trimStart() should be used instead of this.
API Versioned:
From version 21.2.
Returns:
A new string without leading white space characters.

trimRight
trimRight() : String
Removes white space characters at the end of the string. trimEnd() should be used instead of this.
API Versioned:
From version 21.2.
Returns:
A new string without ending white space characters.

trimStart
trimStart() : String
Removes white space characters at the start of the string.
API Versioned:
From version 21.2.
Returns:
A new string without leading white space characters.

valueOf
valueOf() : String
Returns a String value of this object.
Returns:
a String value of this object.