JavaScript: Regex Functions

By Xah Lee. Date: . Last updated: .

Here is 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 a Array of captured groups, or all occurrences. [see String.prototype.match]
str.matchAll(regex)
Return a Iterable Object of all occurrences and captures. [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


BUY
Ξ£JS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc