RegExp \R Escape S1
- Stage: Stage 1
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal introduces the \R escape in regular expressions to match any Unicode line terminator sequence, which is currently difficult to write correctly. It requires the u or v flags and is not supported inside character classes.
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.
Regular Expression \R Escape for ECMAScript
Status
Stage: 1
Champion: Ron Buckton (@rbuckton)
For detailed status of this proposal see TODO, below.
Authors
- Ron Buckton (@rbuckton)
Motivations
NOTE: See https://github.com/rbuckton/proposal-regexp-features for an overview of how this proposal fits into other possible future features for Regular Expressions.
The \R escape sequence matches the various sets of code points that match a unicode line terminator, which can be difficult to write correctly.
Prior Art
See https://rbuckton.github.io/regexp-features/features/line-endings-escape.html for additional information.
Syntax
\R— Matches any line ending character sequence.
NOTE: Requires the
uorvflags, as\Ris currently just an escape forRwithout theuflag.
NOTE: Not supported inside of a character class.
Semantics
- In
uorvmode,\Ris roughly equivalent to the following pattern:- Aligns with
^and$inmumode
- Aligns with
- When not in
uorvmode,\Rwill continue to match the literal characterR.
NOTE: The above example uses atomic groups
(?>)to prevent backtracking when matching\r\n?. Atomic groups is proposed here.
Examples
History
- October 28, 2021 — Proposed for Stage 1 (slides)
- Outcome: Advanced to Stage 1
TODO
The following is a high-level list of tasks to progress through each stage of the TC39 proposal process:
Stage 1 Entrance Criteria
- Identified a "champion" who will advance the addition.
- Prose outlining the problem or need and the general shape of a solution.
- Illustrative examples of usage.
-
High-level API.
Stage 2 Entrance Criteria
- Initial specification text.
-
Transpiler support (Optional).
Stage 3 Entrance Criteria
- Complete specification text.
- Designated reviewers have signed off on the current spec text.
- The ECMAScript editor has signed off on the current spec text.
Stage 4 Entrance Criteria
- Test262 acceptance tests have been written for mainline usage scenarios and merged.
- Two compatible implementations which pass the acceptance tests: [1], [2].
- A pull request has been sent to tc39/ecma262 with the integrated spec text.
- The ECMAScript editor has signed off on the pull request.