JS: Regex Functions

By Xah Lee. Date: . Last updated: .

Here is a overview of regex functions.

str.search(regex)
Return the position of the match. [see String.prototype.search]
str.match(regex)
Return all occurrences (if regex has g flag) or captured groups (if regex has no g flag). [see String.prototype.match]
str.matchAll(regex)
Return all occurrences and captures. [see String.prototype.matchAll]
str.replace(regex, rep)
Return a new string. [see String.prototype.replace]
str.replaceAll(regex, rep)
Return a new string. [see String.prototype.replaceAll]
regex.test(str)
Return true/false. [see RegExp.prototype.test]
regex.exec(str)
Return captured groups. [see RegExp.prototype.exec]

JavaScript, String

JavaScript, Regular Expression

BUY Ξ£JS JavaScript in Depth