-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Regex with a " in character class #28261
Comments
not a bug, but the intended consequence of #22926 In regex, these two are equivalent (and non-matching), since regexes julia> match(r"[\"]", "\\")
julia> match(r"[\\\"]", "\\") On v0.7, what you want is the regex julia> match(r"[\\\\\"]", "\\")
RegexMatch("\\") But it looks like we're not printing the |
That's what I assumed the first one to be, since I got the impression that backslashes don't need escaping in
It implies to me that the only escape sequence is Edit: Having read through #22926 once more now -- OK, it is complicated, but it makes sense and there is no better way. And I see that |
I think we need to rework a lot of the escaping behavior in custom string literals after that change. This means |
#28175 seems related. |
I think we need to mark this as unstable in 1.0 because it needs to be fixed; that can be justified that it's a bugfix but it will likely break some code when we fix it. |
I'm not sure how to fix this --- the escaping rules happen in the parser before we get to the custom string literal code, since otherwise we don't know when the string ends. |
Yeah, I'll have to look at it for a while and think; it may not be fixable. |
I think it's just a printing issue, since it doesn't round-trip correctly. We can't to anything about the escaping rules, unless we want there to be a subset of regexes which cannot be expressed using the string macro (as was true in v0.6 and prior). |
If it's just a printing issue, that's even better since fixing it won't break people's code. |
As far as I can tell the issue here is that the escaping logic is a bit counter-intuitive? But it is working as designed (except for the printing?). And, as was discussed at length in #22926, there might not really be any better solution.
FWIW, one of the proposals in #22926 only excluded trailing backslashes, which would not be a problem for regular expressions (and latex), since they are not allowed anyway. |
I'm sorry, what's an example of a regex that couldn't be expressed using the string macro in 0.6? I understand some strings couldn't be expressed with the raw string macro, but strings and regexes aren't 1:1. PCRE treats |
The sequence |
match(r"[\\\"]", "\\")
does not match on 0.7 whilematch(r"[\"\\]", "\\")
is fine. Unless I am messing up with escape sequences here somehow, either should match as far as I can tell.Tried on 0.7.0-beta2.83 and 0.7.0-beta2.0. It works fine on 0.6, so looks like a regression.
The text was updated successfully, but these errors were encountered: