-
Notifications
You must be signed in to change notification settings - Fork 32
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
Why not just escape every character? #15
Comments
It makes the resulting string longer, other than that it's harmless. This is what some programming languages (Python escapes non alphanumeric strings) do where others escape a strict set (like C#). |
Might be worth mentioning this as a design alternative in the readme, with the pro that it's more future-proof. |
Good idea, I'll add that when I'm in front of a computer :) (you're welcome to if you'd like of course). |
Updated the README, I'll leave this open for a week to see if anyone has any further input on it. |
Following the research https://github.com/benjamingr/RegExp.escape/blob/master/data/other_languages/discussions.md it appears that other languages that used to escape every character have either made exceptions (like Python) or changed it (like Perl). The discussion notes contain links to posts with reasons on why changes were made. |
Python's new regex engine (under development) gives you a choice; either escape all non-alphanumerics, or only metacharacters (and NUL), see https://bitbucket.org/mrabarnett/mrab-regex/src/6193ea4246da272cf18a190c46aa116737067780/regex_3/Python/regex.py?at=default#cl-342 In your discussion you mentioned a problem with wide characters; you ran into the Python |
I think we're good with not escaping every character. I want to focus on the discussion about big set vs readable set. |
Is there any reason to only escape a specific subset? It's harmless to add slashes, right?
The text was updated successfully, but these errors were encountered: