-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(regexp): add escape function #3334
Conversation
f87da6b
to
4077a39
Compare
Thanks for the suggestion! I think the directory name should be |
This is probably one of those "gif/jif" things that everyone has their own strong opinions about, but it seems like Still, this function would typically be used when interpolating/concatenating content into strings passed to the I started writing this answer arguing in favor of |
+1 for |
@lionel-rowe Thanks for updating to I now wonder if we could make API name just |
Done and done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Fixes #3330
Escaping is fairly conservative to account for context sensitivity and forward compatibility with the
v
flag — the only non-alphanumeric printable ASCIIS that aren't escaped are"'_
, and of the characters that are escaped, almost half use the most conservative\x
hex notation. That could be reduced a little (but not much) by ignoring characters inClassSetReservedDoublePunctuator
, which only need escaping if repeated adjacent to each other in a within a character class in av
-flagged regex.