-
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: doc: lead with the precise syntax rather than referring to Perl, Python, etc. #39405
Comments
It's worth noting that Go's regular expression engine doesn't aim to be compatible with Perl's (PCRE). Our implementation is aimed towards being compatible with |
Okay that makes sense. Thanks for the quick response. I think it'd be worth making that very obvious in the regexp docs (again, apologies if it already is and I missed it). My uneducated view is that most golang users expect it be compatible with I think it'd also be beneficial to the docs to list some of the special characters and their equivalencies, or include a link to the re2 syntax page. |
This is documented at https://golang.org/pkg/regexp/syntax. |
Hey thanks for that. Below is the first paragraph in the
Given this thread, I think this is a bit misleading. It should read:
|
@ianlancetaylor - please consider this change. I think it'd be helpful to make this a little more explicit. |
I reopened the issue. Want to send a change? |
Sure will do. Thank you! |
It seems weird to me that the first thing the Go regexp documentation does is link to another project, i.e., the docs for the C++ RE2 syntax. Could we link to Go documentation -- https://golang.org/pkg/regexp/syntax/ -- instead? |
@benhoyt Do you like this wording? Forgive me if @Jarch09 has already submitted a change. |
@qbradq I like that wording, yes. |
Change https://golang.org/cl/243399 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
darwin/amd64What did you do?
\s
is not matching hair spaces (whereas perl regex does)Here's a go playground link
What did you expect to see?
It should match the white space.
What did you see instead?
It did not recognize the hair space as valid white space.
If this is indeed the intended behavior, the docs should be more clear that golang's regex does not conform with perl's and will not match all of the standard regex special characters.
If the docs already say this loudly and clearly and I just missed that section, apologies for being an idiot.
The text was updated successfully, but these errors were encountered: