From 8ccf5761186f16bcdb4531f97e16db2c92ab79d2 Mon Sep 17 00:00:00 2001 From: Steven Levithan Date: Fri, 19 Jul 2024 14:52:39 +0200 Subject: [PATCH] JS regex evolution tweaks --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fdc009b..65cd3d7 100644 --- a/README.md +++ b/README.md @@ -316,13 +316,13 @@ Many regexes found online are low quality. It's risky to use regexes you don't f - Getter `RegExp.prototype.flags`. - Can subclass `RegExp`, plus `RegExp.prototype[Symbol.match`/`replace`/`search`/`split]` and `RegExp[Symbol.species]` for use in subclasses. - Use `RegExp` to copy a regex, optionally with new flags. -- ES2018 added [flag `s`](https://github.com/tc39/proposal-regexp-dotall-flag) (`dotAll`), [lookbehind](https://github.com/tc39/proposal-regexp-lookbehind), [named capture](https://github.com/tc39/proposal-regexp-named-groups), and [Unicode properties](https://github.com/tc39/proposal-regexp-unicode-property-escapes) via `\p{…}` and `\P{…}` behind flag `u` (see [list](https://github.com/mathiasbynens/regexpu-core/blob/main/property-escapes.md)). +- ES2018 added [flag `s`](https://github.com/tc39/proposal-regexp-dotall-flag) (`dotAll`), [lookbehind](https://github.com/tc39/proposal-regexp-lookbehind), [named capture](https://github.com/tc39/proposal-regexp-named-groups), and (behind flag `u`) [Unicode properties](https://github.com/tc39/proposal-regexp-unicode-property-escapes) via `\p{…}` and `\P{…}` (see [list](https://github.com/mathiasbynens/regexpu-core/blob/main/property-escapes.md)). - ES2020 added string method [`matchAll`](https://github.com/tc39/proposal-string-matchall) (which returns an iterator), plus `RegExp.prototype[Symbol.matchAll]`. +- ES2021 added string method [`replaceAll`](https://github.com/tc39/proposal-string-replaceall). When given a regex, the only difference from ES3's `replace` is that it throws if not using flag `g`. - ES2022 added [flag `d`](https://github.com/tc39/proposal-regexp-match-indices) (`hasIndices`), which provides start/end indices for matched substrings. - ES2024 added [flag `v`](https://github.com/tc39/proposal-regexp-v-flag) (`unicodeSets`) \[[*explainer*](https://v8.dev/features/regexp-v-flag)] as an upgrade to flag `u` (can't be used together), which adds a set of multicharacter "properties of strings" to `\p{…}`, multicharacter elements within character classes via `\p{…}` and `\q{…|…}`, nested character classes, set operators `[…--…]` and `[…&&…]`, and different escaping rules within character classes. It also fixes case-insensitive matching for doubly-negated `[^\P{…}]`. -> Each edition from ES2019 to ES2023 added additional Unicode properties that can be used via `\p{…}` and `\P{…}` (see [lists](https://github.com/eslint-community/regexpp/blob/main/src/unicode/properties.ts)). ES2021 added [`replaceAll`](https://github.com/tc39/proposal-string-replaceall), which optionally accepts a `RegExp`, but it behaves identically to ES3's `replace` when given a regex as the search. - +> Each edition from ES2019 to ES2023 added additional Unicode properties that can be used via `\p{…}` and `\P{…}` (see [lists](https://github.com/eslint-community/regexpp/blob/main/src/unicode/properties.ts)).
See also