-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
regexp: compiling incorrectly #59007
Comments
cc @rsc |
The regexp |
From https://github.com/google/re2/wiki/Syntax , it says
That makes me think the OP's regexp is |
No, re2 flavor regex don't bind that way, see https://github.com/google/re2/wiki/Syntax
https://go.dev/play/p/EQ6nkEEHJCT
Notice the second one parsed as the string An prefix followed by a capital letter with a character class with capital and lower case seems broken, larger prefixes are still broken (see the play link above) |
I think that
Given the odd pattern as above ( In In At first glance the logic in |
Even if that was the case, there would still be a problem because |
Apologies for being confused. |
$ perl -E 'say ("0a" =~ /0A|0[Aa]/)'
1
$ go version
go version go1.21.5 darwin/arm64
$ go run github.com/dolmen-go/goeval@latest -i=regexp -i=fmt 'fmt.Println(regexp.MustCompile("0A|0[Aa]").MatchString("0a"))'
false |
@apmckinlay You must use the Here is your example fixed: https://go.dev/play/p/OrLoZxhMwMN But the issue is still there. |
Fixing `Equal` method in `regexp/syntax` package fixes compilation of some alternate patterns like `0A|0[aA]`. Fixes golang#59007
Fixing Equal method in regexp/syntax package fixes compilation of some alternate patterns like "0A|0[aA]". Fixes golang#59007
Change https://go.dev/cl/569735 mentions this issue: |
Fixing Equal method in regexp/syntax package fixes compilation of some alternate patterns like "0A|0[aA]". Fixes golang#59007
Fixing Equal method in regexp/syntax package fixes compilation of some alternate patterns like "0A|0[aA]". Fixes golang#59007
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
and with 1.19 on the Go Playground
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
(https://go.dev/play/p/jCLPp8AXnJB)
What did you expect to see?
true
What did you see instead?
false
I tested on regex101 to confirm that this should match.
(Strangely, it shows golang matching)
It appears to compile incorrectly. Simplify doesn't seem to matter.
The text was updated successfully, but these errors were encountered: