JavaScript: Regex Functions

By Xah Lee. Date: . Last updated: .

Here's a overview of regex functions. (For a basic intro to regex, see RegExp Tutorial)

str.search(regex)
Return the position of the match. [see String.prototype.search]
str.match(regex)
Return captured groups or all occurrences. [see String.prototype.match]
str.matchAll(regex)
Return a Iterator of all occurrences. [see String.prototype.matchAll]
str.replace(regex,str_or_func)
Return a new string. [see String.prototype.replace]
str.replaceAll(regex,str_or_func)
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

βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc