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 capture group introspection not exposed by the C API #279

Closed
davidblewett opened this issue Sep 11, 2016 · 4 comments
Closed

Named capture group introspection not exposed by the C API #279

davidblewett opened this issue Sep 11, 2016 · 4 comments

Comments

@davidblewett
Copy link
Contributor

The C API exposes an iterator over all captures (rure_iter_next_captures), and can return the index of a given capture group name (rure_capture_name_index). The Rust Regex struct has a capture_names iterator, but that doesn't appear to be exposed at the C level.

I don't see a way to retrieve the capture group name while iterating over the set of captures (i.e., given the index of a particular capture give me the corresponding name, hypothetically rure_capture_index_name), or to return the list of capture group names (rure_iter_capture_groups, for example).

@BurntSushi
Copy link
Member

Ah yup, it looks like exposing the capture_names iterator in some form in the C API should fix this.

@davidblewett
Copy link
Contributor Author

I came upon this while working on Python bindings ( current WIP here: https://github.com/rust-lang-nursery/regex/compare/master...davidblewett:rure-python?expand=1 ). I wanted to implement the groupdict method, similar to Python's re.MatchObject: https://docs.python.org/2/library/re.html#re.MatchObject.groupdict .

I'm new to Rust, and have never really used C. I can take a crack at it some time this week.

@BurntSushi
Copy link
Member

@davidblewett That'd be awesome! I'm not a C expert either but I'd be happy to help mentor you if you'd like. I'm on IRC in the evenings during the week.

@BurntSushi
Copy link
Member

Fixed in #282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants