`@std/regexp/escape` vs `RegExp.escape` (newly Stage 3!)
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
Mainly a tracking issue, probably (?) no action needed for now.
The [`RegExp.escape`](https://github.com/tc39/proposal-regex-escaping) proposal has overcome its TC39 deadlock and is now at Stage 3!
The exact details of the implementation in [the spec](http://tc39.es/proposal-regex-escaping/) differ somewhat from `@std/regexp/escape`, but as far as I can tell, the only _functional_ difference is that alphanumeric chars get automatically escaped at the start of the string, such that `RegExp.escape('7_8_9')` becomes `'\\x37_8_9'`, which sacrifices a certain amount of readability in exchange for allowing safe interpolation immediately after the sequences `\0`, `\`, and `\c`.
Not sure if desirable or worthwhile to replace at this stage, but I've created a [lightweight polyfill](https://github.com/lionel-rowe/regexp-escape-polyfill) that passes the test262 tests and could work as a drop-in replacement for `@std/regexp/escape`. But probably better to just wait until implementations drop and then deprecate `@std/regexp/escape`.
Contributor guide
Assessment
This issue has not been assessed yet.