tc39 / proposal-regex-escaping

Proposal for investigating RegExp escaping for the ECMAScript standard
http://tc39.es/proposal-regex-escaping/
Creative Commons Zero v1.0 Universal
363 stars 32 forks source link

`/u` flag vs. `/v` flag #55

Closed rauschma closed 11 months ago

rauschma commented 1 year ago

There is no way of escaping that works in all scenarios:

[<] [\<]
Neither /u nor /v
/u
/v

What’s the best approach then? Only support /v?

More information: https://github.com/tc39/proposal-regexp-v-flag/issues/71

lionel-rowe commented 1 year ago

For completeness — I know it's been discussed in other issues as a solution to various issues of context-sensitivity, though it's suboptimal in terms of conciseness and readability:

[<] [\<] [\x3c]
Neither /u nor /v
/u
/v
bakkot commented 1 year ago

One option (mentioned elsewhere and elsewhere) is to just make all of those escapes legal (as identity escapes) in u-mode regexes. I think that's the easiest - we wouldn't want to give those different meanings than in v-mode, I think.

eemeli commented 12 months ago

It seems like adding a second flags argument to RegExp.escape() would provide a pretty ergonomic solution (as in the RegExp constructor), if there are differences in required escapes.