Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

/u flag vs. /v flag #55

Closed
rauschma opened this issue Oct 21, 2022 · 3 comments
Closed

/u flag vs. /v flag #55

rauschma opened this issue Oct 21, 2022 · 3 comments

Comments

@rauschma
Copy link

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: tc39/proposal-regexp-v-flag#71

@lionel-rowe
Copy link
Contributor

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
Copy link
Collaborator

bakkot commented Mar 13, 2023

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
Copy link
Member

eemeli commented Sep 19, 2023

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.

@ljharb ljharb mentioned this issue Sep 26, 2023
33 tasks
@ljharb ljharb closed this as completed in 9c55324 Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants