Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
RegExp static properties that expose the last match state globally are deprecated. See deprecated RegExp features for more information.
RegExp.lastParen static accessor property returns the last parenthesized substring match, if any.
RegExp["$+"] is an alias for this property.
lastParen is a static property of
RegExp, you always use it as
RegExp["$+"], rather than as a property of a
RegExp object you created.
The value of
lastParen updates whenever a
RegExp (but not a
RegExp subclass) instance makes a successful match. If no matches have been made, or if the most recent regex execution contains no capturing groups,
lastParen is an empty string. The set accessor of
undefined, so you cannot change this property directly.
const re = /(hi)/g; re.test("hi there!"); RegExp.lastParen; // "hi" RegExp["$+"]; // "hi"
|Legacy RegExp features |
BCD tables only load in the browser