JS-native operations on strings. Alternative to JSStringOps from Scala.js
- Companion:
- object
Value members
Concrete methods
Alternatives:
-
If the
gflag is used, all results matching the complete regular expression will be returned, but capturing groups will not. -
if the
gflag is not used, only the first complete match and its related capturing groups are returned. In this case, the returned item will have additional properties as described in the docs.
Alternatives:
-
If you only want the first match found, you might want to use
myJsRegExp.exec(str) -
If you need to know if a string matches a regular expression, use
myJsRegExp.test(str)
- See also:
Returns a new string consisting of the single UTF-16 code unit located at
index in the string.
Returns a new string consisting of the single UTF-16 code unit located at
index in the string.
- If index is out of range, returns an empty string.
- See also:
Returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.
Returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.
- If
indexis out of range, charCodeAt() returns NaN.
- See also:
Returns a non-negative integer that is the Unicode code point value at the given position in the string.
Returns a non-negative integer that is the Unicode code point value at the given position in the string.
-
If there is no element at
pos, returns undefined. -
If the element at
posis a UTF-16 high surrogate, returns the code point of the surrogate pair. -
If the element at
posis a UTF-16 low surrogate, returns only the low surrogate code point.
!! Not supported by IE !!
- See also:
- Value parameters:
- length
If provided, it is used as the length of the string in which we're searching. Defaults to its real length. !! Not supported by IE !!
- searchString
The characters to search for.
- See also:
Returns the index of the first occurrence of the specified substring at an index greater than or equal to the specified number.
Returns the index of the first occurrence of the specified substring at an index greater than or equal to the specified number.
- Returns -1 if not found.
- Value parameters:
- fromIndex
The lowest index at which the found substring can begin, for it to be found. Defaults to 0.
- See also:
Returns the index of the last occurrence of the specified substring at an index less than or equal to the specified number.
Returns the index of the last occurrence of the specified substring at an index less than or equal to the specified number.
- Returns -1 if not found.
- Value parameters:
- fromIndex
The highest index at which the found substring can begin, for it to be found. Defaults to +Infinity
- See also:
Return the length of the string, in UTF-16 code units.
Return the length of the string, in UTF-16 code units.
- See also:
Returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order: negative number if referenceStr occurs before compareString; positive if the referenceStr occurs after compareString; 0 if they are equivalent.
Returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order: negative number if referenceStr occurs before compareString; positive if the referenceStr occurs after compareString; 0 if they are equivalent.
locales and options customize the behavior of the function and let
applications specify the language whose formatting conventions should
be used.
!! Not supported by Android WebView !!
- See also:
Returns the Unicode Normalization Form of the string.
Returns the Unicode Normalization Form of the string.
!! Not supported by IE !!
- Value parameters:
- form
One of "NFC", "NFD", "NFKC", or "NFKD", specifying the Unicode Normalization Form
- See also:
Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string.
Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string.
!! Not supported by IE !!
- See also:
Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the start of the current string.
Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the start of the current string.
!! Not supported by IE !!
- See also:
Returns a string that repeats the current string count times
Returns a string that repeats the current string count times
!! Not supported by IE !!
- See also:
- Value parameters:
- replacement
Note: this is parsed for special patterns! See docs. !! If you don't want special patterns to be parsed out of
replacement, use the version of this method with areplacerfunction. !!- what
Note: if String, only the first occurrence will be replaced. If RegExp, depends on the
gflag.
- See also:
- Value parameters:
- replacer
Accepts the substring to be replaced, and returns what to replace it with. Note that JS can actually provide more data to this function, but we don't expose that. See docs.
- what
Note: if String, only the first occurrence will be replaced. If RegExp, depends on the
gflag.
- See also:
- Value parameters:
- replacement
Note: this is parsed for special patterns! See docs. !! If you don't want special patterns to be parsed out of
replacement, use the version of this method with areplacerfunction. !! !! Not supported by IE, not supported by MobileSafari < 13.4 !!- what
If js.RegExp, must be global, or this will throw.
- See also:
- Value parameters:
- replacer
Accepts the substring to be replaced, and returns what to replace it with. Note that JS can actually provide more data to this function, but we don't expose that. See docs. !! Not supported by IE !!
- what
If js.RegExp, must be global, or this will throw.
- See also:
Returns the index of the first match between the regular expression and the given string, or -1 if no match was found.
Returns the index of the first match between the regular expression and the given string, or -1 if no match was found.
- See also:
Extracts the text from the string and returns it.
Extracts the text from the string and returns it.
If beginIndex is negative, slice() begins extraction from the end.
- Value parameters:
- beginIndex
The zero-based index at which to begin extraction.
- endIndex
The zero-based index before which to end extraction. The character at this index will not be included. If endIndex is omitted, the entire remainder of the string is extracted.
- See also:
If separator is does not occur in str, the returned array contains one
element consisting of the entire string.
If separator is does not occur in str, the returned array contains one
element consisting of the entire string.
If separator appears at the beginning (or end) of the string, it still
has the effect of splitting. The result is an empty (i.e. zero length)
string, which appears at the first (or last) position of the returned
array.
If separator is an empty string (""), str is converted to an array of
each of its UTF-16 "characters".
- Value parameters:
- limit
Max number of substrings to be included in the array. Any leftover text is not included in the array at all. If limit is 0, [] is returned.
- See also:
- Value parameters:
- position
The position in the string at which to start searching. Defaults to 0. !! Not supported by IE !!
- searchString
The characters to search for.
- See also:
Returns characters from indexStart up to but not including indexEnd.
Returns characters from indexStart up to but not including indexEnd.
If indexEnd is omitted, the entire remainder of the string is returned.
- See also:
Returns a new string with the whitespace from both ends of the original string removed. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
Returns a new string with the whitespace from both ends of the original string removed. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
- See also:
Like trim(), but only trims the end of the string
Like trim(), but only trims the end of the string
!! Not supported by IE, not supported by MobileSafari < 12 !!
- See also: