regex.replace()
Last updated
Was this helpful?
regex.replace(haystack, pattern, replacement) replaces the first occurrence of a regex pattern in a string with a replacement string.
if haystack and replacement are strings and pattern matches, returns a new string with the first match replaced by replacement.
otherwise, returns null.
// remove leading whitespace
regex.replace(text, /^\s+/, "")Last updated
Was this helpful?
Was this helpful?