String API Flashcards
string.match(regexp)
Used to retrieve the matches when matching a string against a regular expression.
string.indexOf(searchValue[, fromIndex])
Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, returns -1 if the value is not found.
string.localeCompare(compareString)
Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
string.charAt(index)
Returns the specified character from a string.
Removes whitespace from the right end of the string.
string.trimRight()
Removes whitespace from the left end of the string.
string.trimLeft()
Returns the specified character from a string.
string.charAt(index)
Executes the search for a match between a regular expression and this String object.
string.search(regexp)
Used to retrieve the matches when matching a string against a regular expression.
string.match(regexp)
Returns the characters in a string beginning at the specified location through the specified number of characters.
string.substr(start[, length])
Combines the text of two or more strings and returns a new string.
string.concat(string2, string3[, …, stringN])
Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, returns -1 if the value is not found.
string.indexOf(searchValue[, fromIndex])
string.lastIndexOf(searchValue[, fromIndex])
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex.
string.substr(start[, length])
Returns the characters in a string beginning at the specified location through the specified number of characters.
string.search(regexp)
Executes the search for a match between a regular expression and this String object.
Extracts a section of a string and returns a new string.
string.slice(beginslice[, endSlice])
- if not specified, endSlice is the end of the string
- beginSlice and endSlice can be negative numbers
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex.
string.lastIndexOf(searchValue[, fromIndex])
string.slice(beginslice[, endSlice])
Extracts a section of a string and returns a new string.
- beginSlice and endSlice can be negative
- if endSlice ommited, it extracts until the end of the string
string.trim()
Removes whitespace from both ends of the string.
str.replace(regexp|substr, newSubStr|function[, Non-standard flags]);
Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match.
Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match.
str.replace(regexp|substr, newSubStr|function[, Non-standard flags]);
string.concat(string2, string3[, …, stringN])
Combines the text of two or more strings and returns a new string.
Splits a String object into an array of strings by separating the string into substrings.
string.split([separator][, limit])
string.trimLeft()
Removes whitespace from the left end of the string.