RegExp.lastMatch ($&) - 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

deprecated RegExp features

Note: All RegExp static properties that expose the last match state globally are deprecated. See deprecated RegExp features for more information.

String.prototype.replace()

Because lastMatch is a static property of RegExp, you always use it as RegExp.lastMatch or RegExp["$&"], rather than as a property of a RegExp object you created.

RegExp.lastParen ($+)

RegExp.leftContext ($`)

RegExp.rightContext ($')

RegExp.$1, …, RegExp.$9

Learn how to contribute

This page was last modified on Aug 21, 2026 by MDN contributors.

[Symbol.matchAll]()

[Symbol.replace]()

[Symbol.hasInstance]()

__defineGetter__()

__defineSetter__()

__lookupGetter__()

__lookupSetter__()

propertyIsEnumerable()

Community resources