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/syntax: "single character" docs are misleading #8505
Labels
Milestone
Comments
Comment 2 by steven.hartland@multiplay.co.uk: Here's an example: http://play.golang.org/p/uX83Si_90p The output is: Match by Set (Perl): true Match by Class (Perl): false Match by Class (POSIX): true So the character class, in this case [:xdigit:] only works in POSIX mode not in Perl mode |
Comment 3 by steven.hartland@multiplay.co.uk: Here's an example: http://play.golang.org/p/uX83Si_90p The output is: Match by Set (Perl): true Match by Class (Perl): false Match by Class (POSIX): true So the character class, in this case [:xdigit:], only works in POSIX mode not in Perl mode |
I'm sorry, I don't understand how your test case demonstrates that. What I'm looking for is a test case where you use the same regexp for Compile and CompilePOSIX, but get different results. What your test case appears to demonstrate is that [:xdigit:] is not equivalent to [0-9A-Fa-f], which may be a bug but is not the same as the bug you are reporting. |
Comment 5 by steven.hartland@multiplay.co.uk: Sorry, that was a cut and paste error, which caused my initial confusion as to the real nature of the issue. On further investigation it appears that the actual problem is that "named" ASCII Character classes can only be used within a character class. So if you want to match an xdigit you must use [[:xdigit:]] and not just [:xdigit:] Example: http://play.golang.org/p/iGziut5Vi6 The confusion comes from regexp/syntax docs where in the "Single characters:" block at the top it lists items such as: \d Perl character class [:alpha:] ASCII character class \d can be used directly in a regexp but apparently not so for named ASCII character classes such as [:alpha:] Additionally in the docs there is: Perl character classes: \d digits (== [0-9]) ... ASCII character classes: [:digit:] digits (== [0-9]) Here we see the Perl character class \d, which can be used directly, documented as being identical to the ASCII character class [:digit:] which can not be used directly and needs enclosing []'s An example of this is: http://play.golang.org/p/240L99E6F4 In Stefan Schroeder's Golang Regex Tutorial: https://github.com/StefanSchroeder/Golang-Regex-Tutorial/blob/master/01-chapter1.markdown He clearly states this quirk of ASCII Character classes with: "Note that you have to wrap an ASCII character class in []. " Hope this clarifies the issue and sorry again for my initial inaccurate report. |
Thanks. This is also re2 issue #116. |
CL https://golang.org/cl/155890043 mentions this issue. |
This issue was closed by revision 85fd0fd. Status changed to Fixed. |
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Generated using re2/doc/mksyntaxgo. Fixes golang#8505. LGTM=iant R=r, iant CC=golang-codereviews https://golang.org/cl/155890043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 26, 2018
Generated using re2/doc/mksyntaxgo. Fixes golang#8505. LGTM=iant R=r, iant CC=golang-codereviews https://golang.org/cl/155890043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Generated using re2/doc/mksyntaxgo. Fixes golang#8505. LGTM=iant R=r, iant CC=golang-codereviews https://golang.org/cl/155890043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 30, 2018
Generated using re2/doc/mksyntaxgo. Fixes golang#8505. LGTM=iant R=r, iant CC=golang-codereviews https://golang.org/cl/155890043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by steven.hartland@multiplay.co.uk:
The text was updated successfully, but these errors were encountered: