Closed rauschma closed 11 months 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 |
❌ | ✅ | ✅ |
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.
There is no way of escaping that works in all scenarios:
[<]
[\<]
/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