Skip to content
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

please support \" and \' as equivalent to " and ' respectively #522

Closed
zackw opened this issue Oct 8, 2018 · 2 comments
Closed

please support \" and \' as equivalent to " and ' respectively #522

zackw opened this issue Oct 8, 2018 · 2 comments

Comments

@zackw
Copy link

zackw commented Oct 8, 2018

It would enhance compatibility with other regex engines if regex understood \" and \' as equivalents of " and '.

This came up for me when trying to use Rust's regexes from Python (Python's built-in regex module doesn't have an equivalent of RegexSet). Python's raw string literals do recognize some backslash escapes for purpose of deciding where the literal ends, so for instance r"<a href=\"https?://([a-z0-9.-]+)/robots.txt\">" is a single string literal — but they don't convert those escapes, so the contents of the parsed string are the same as if you had written "<a href=\\\"https?://([a-z0-9.-]+)/robots.txt\\\">". Python's built-in regex module understands this to mean the same thing as if the quote characters were not escaped., but regex will barf on the \".

This could also come up in any other context where backslash escapes quote characters but is not removed from the input in the process. For instance, some parsers for Windows-style .cfg files do this.

@RReverser
Copy link
Contributor

(nvm my previous comment, sounds like you want the same)

@BurntSushi
Copy link
Member

I think this is a dupe of #501 (I've just renamed that issue to have a better title). I've also left a comment in that issue responding to your request in an effort to centralize discussion: #501 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants