String API Reference
JavaScript String methods for splitting, replacing, matching and transforming text.
String
Immutable sequence of UTF-16 code units.
str.split(separator?, limit?)Split the string into an array of substrings.
Returns: string[]
str.replace(pattern, replacement)Return a new string with the first match of pattern replaced. Use replaceAll for all matches.
Returns: string
str.match(regexp)Return the result of matching a string against a regular expression.
Returns: Array | null
str.trim()Return a new string with whitespace removed from both ends.
Returns: string
str.padStart(targetLength, padString?)Pad the string from the start with padString until it reaches targetLength.
Returns: string
str.padEnd(targetLength, padString?)Pad the string from the end with padString until it reaches targetLength.
Returns: string
str.includes(searchString, position?)Return true if searchString is found within the string.
Returns: boolean
str.startsWith(searchString, position?)Return true if the string starts with searchString.
Returns: boolean
str.endsWith(searchString, length?)Return true if the string ends with searchString.
Returns: boolean
str.repeat(count)Return a new string consisting of count copies of the original.
Returns: string
str.substring(start, end?)Return the substring from start to end (end excluded).
Returns: string