RegExp Atomic Groups & Possessive Quantifiers ?
- Stage: Unstaged
- Status: Inactive
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal introduces atomic groups and possessive quantifiers to JavaScript RegExps to prevent catastrophic backtracking. Atomic groups lock their match and disallow backtracking, while possessive quantifiers prevent backtracking after a token matches.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
proposal-regexp-atomic-and-possessive
A proposal to add Atomic Groups and Possessive Quantifiers to RegExps.
Atomic Groups
Atomic groups, denoted by (?>TEXT_TO_MATCH), prevent backtracking once
the group matches and "locks". Even if backtracking into an alternate
branch could allow a full match, the atomic group will not unlock.
Possessive Quantifiers
Possessive quantifiers, denoted by using + after a quantifier, prevent
backtracking once the token has matched. Even if backtracking would
allow a full match, the possessive quantifier will not allow it.
Champions
- Justin Ridgewell (@jridgewell)
Status
Current Stage: 0
Motivation
JavaScript's Regular Expressions are great, but developers can unintentionally write one with "catastrophic backtracking". These regexs can completely freeze the program, and is especially dangerous for servers.
Atomic Groups and Possessive Quantifiers allow developers to write understandable performance guarantees. Since they do not allow backtracking, they'll never suffer exponential execution time.