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: using (?P<name>re) isn't supported as such #2440

Closed
mark-summerfield opened this issue Nov 10, 2011 · 8 comments
Closed

regexp: using (?P<name>re) isn't supported as such #2440

mark-summerfield opened this issue Nov 10, 2011 · 8 comments
Milestone

Comments

@mark-summerfield
Copy link

Since none of the regexp functions return a "match object", but rather a slice
or slice of slices of actual matches, using a named capture group doesn't actually buy
you anything.

One easy solution is to just mention in the docs that named captures aren't supported.

Another solution might be to have a FindAllStringNamedMatch() function or similar.

And another would be to return some kind of "match object" (like Python does
with match.group() etc).

(I have no preferences/views, merely noting the fact + some ideas.)
@rsc
Copy link
Contributor

rsc commented Nov 11, 2011

Comment 1:

Owner changed to @rsc.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2011

Comment 2:

Labels changed: added priority-later, removed priority-medium.

@rsc
Copy link
Contributor

rsc commented Dec 12, 2011

Comment 3:

Labels changed: added priority-go1.

@robpike
Copy link
Contributor

robpike commented Jan 13, 2012

Comment 4:

Owner changed to builder@golang.org.

@dsymonds
Copy link
Contributor

Comment 5:

Owner changed to @rsc.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Jan 19, 2012

Comment 6:

This issue was closed by revision 21d3721.

Status changed to Fixed.

@mark-summerfield
Copy link
Author

Comment 7:

I can't see that the new regexp.SubexpNames() method buys much (but perhaps that's my
mistake).
ISTM that what's needed are something like:
regexp.Capture(int) (string, error)
regexp.CaptureOf(string) (string, error)
which return the index-th or named capture's matching text and nil or an empty string
and an error (either no such index/name, or no such match).

@rsc
Copy link
Contributor

rsc commented Jan 20, 2012

Comment 8:

I'm treating that functionality as part of 2736.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants