Home

Awesome

<!--#region:intro-->

Regular Expression \R Escape for ECMAScript

<!--#endregion:intro--> <!--#region:status-->

Status

Stage: 1
Champion: Ron Buckton (@rbuckton)

For detailed status of this proposal see TODO, below.

<!--#endregion:status--> <!--#region:authors-->

Authors

<!--#endregion:authors--> <!--#region:motivations-->

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.

<!--#endregion:motivations--> <!--#region:prior-art-->

Prior Art

See https://rbuckton.github.io/regexp-features/features/line-endings-escape.html for additional information.

<!--#endregion:prior-art--> <!--#region:syntax-->

Syntax

NOTE: Requires the u or v flags, as \R is currently just an escape for R without the u flag.

NOTE: Not supported inside of a character class.

<!--#endregion:syntax--> <!--#region:semantics-->

Semantics

NOTE: The above example uses atomic groups (?>) to prevent backtracking when matching \r\n?. Atomic groups is proposed here.

<!--#endregion:semantics--> <!--#region:examples-->

Examples

// split lines regardless of line termiantor style
const lines = fs.readFileSync("file.txt", "utf8").split(/\R/ug);
<!--#endregion:examples--> <!--#region:api--> <!-- # API --> <!--#endregion:api--> <!--#region:grammar--> <!-- # Grammar ```grammarkdown ``` --> <!--#endregion:grammar--> <!--#region:references--> <!-- # References > TODO: Provide links to other specifications, etc. * [Title](url) --> <!--#endregion:references-->

History

<!--#region:todo-->

TODO

The following is a high-level list of tasks to progress through each stage of the TC39 proposal process:

Stage 1 Entrance Criteria

Stage 2 Entrance Criteria

Stage 3 Entrance Criteria

Stage 4 Entrance Criteria

<!--#endregion:todo--> <!-- The following links are used throughout the README: -->