RegExp - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

Regular expressions chapter

The RegExp object is used for matching text with a pattern.

regular expression reference

The RegExp object is used for matching text with a pattern.

[Symbol.replace]()

String.prototype.endsWith()

String.prototype.matchAll()

[Symbol.matchAll]()

[Symbol.replace]()

Special handling for regexes

Note: Whether something is a "regex" can be duck-typed. It doesn't have to be a RegExp!

Special handling for regexes

Note: Whether something is a "regex" can be duck-typed. It doesn't have to be a RegExp!

deprecated RegExp properties

Note that several of the RegExp properties have both long and short (Perl-like) names. Both names always refer to the same value. (Perl is the programming language from which JavaScript modeled its regular expressions.)

RegExp.$1, …, RegExp.$9

Static read-only properties that contain parenthesized substring matches.

RegExp.lastMatch ($&)

Static read-only properties that contain parenthesized substring matches.

RegExp.lastParen ($+)

Static read-only properties that contain parenthesized substring matches.

RegExp.leftContext ($`)

Static read-only properties that contain parenthesized substring matches.

RegExp.rightContext ($')

Static read-only properties that contain parenthesized substring matches.

RegExp[Symbol.species]

Static read-only properties that contain parenthesized substring matches.