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

regexp: add generic character types \h \v #22107

Closed
kamphaus opened this issue Oct 2, 2017 · 3 comments
Closed

regexp: add generic character types \h \v #22107

kamphaus opened this issue Oct 2, 2017 · 3 comments

Comments

@kamphaus
Copy link

@kamphaus kamphaus commented Oct 2, 2017

go version
go version go1.9 windows/amd64

What did you do?

https://play.golang.org/p/36811_BjSY

What did you expect to see?

true

What did you see instead?

error parsing regexp: invalid escape sequence: '\h'

Proposal

It would be good if the generic character types \h and \v could be added to the regexp package.
This would better align with the PCRE specification.
http://www.pcre.org/original/doc/html/pcrepattern.html#genericchartypes

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 2, 2017

Change https://golang.org/cl/67590 mentions this issue: regexp: add generic character types \h \H \v \V

@ianlancetaylor ianlancetaylor changed the title Regexp add generic character types \h \v regexp: add generic character types \h \v Oct 2, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Oct 2, 2017
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 2, 2017

CC @rsc

@rsc
Copy link
Contributor

@rsc rsc commented Oct 2, 2017

Sorry, but no.

It was an explicit design choice for RE2 that the Perl character classes are ASCII-only, as 'go doc regexp/syntax' says. It was also an explicit design choice to keep RE2 and Go's regexp as close as possible but not to try to keep up with Perl as Perl's syntax continues to evolve. (\h \H \v \V were added in Perl 5.10; in the case of \v, they redefined the meaning of the existing \v!)

@rsc rsc closed this Oct 2, 2017
kamphaus added a commit to kamphaus/go that referenced this issue Oct 3, 2017
To better align with the PCRE specification, the generic types \h \H \v \V
have been added to the regexp syntax.
http://www.pcre.org/original/doc/html/pcrepattern.html#genericchartypes

Fixes golang#22107

Change-Id: Ide95bad8d5f566654f0c34c8c57edb257fe68336
@golang golang locked and limited conversation to collaborators Oct 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.