Skip to content

Feature: Iterate over the capture groups of a match #7

Closed
@RageKnify

Description

I'm working on boa-dev/boa#686, and really missing the ability to do something like:

for group in mat.groups() {
    // use group
}

I have implemented it with the following struct serving as the iterator:

pub struct Groups<'m> {
    mat: &'m Match,
    i: usize,
}

The Iterator returns Option<Option<Range>> ( Some(None) is possible because a capture group might not exist if it is optional).
I'll open a PR soon.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions