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

Named subpatterns in regex #11362

Closed
malmaud opened this issue May 20, 2015 · 4 comments
Closed

Named subpatterns in regex #11362

malmaud opened this issue May 20, 2015 · 4 comments

Comments

@malmaud
Copy link
Contributor

malmaud commented May 20, 2015

Unless I'm missing something, RegexMatch objects don't provide a way to access named captures by name, but only by position; eg

match(r"(?P<hour>\d\d):(?P<minute>\d\d)", "Time is 12:45")
RegexMatch("12:45", 1="12", 2="45")
@kmsquire
Copy link
Member

Related: #1448 (somewhat related: #1820, #1289)

Regex's could use some love if someone wants to put in the time.

@stevengj
Copy link
Member

Basically, this would involve wrapping the pcre2_substring_copy_byname function in PCRE? Couldn't we just implement a getindex(::RegexMatch, key::String) method that exposes this, so you could do m = match(...); m["hour"]?

@tkelman
Copy link
Contributor

tkelman commented May 20, 2015

We aren't binding PCRE2 yet, we're still on 8.36. We might need to upgrade to get some newer functionality. Regexes should probably be updated to return Nullables if someone wants to dig into that code.

@malmaud
Copy link
Contributor Author

malmaud commented Jul 8, 2015

Implemented by #11566

@malmaud malmaud closed this as completed Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants