Skip to content

[Feature request]: match multiple regular expressions simultaneously obtaining capture groups #822

@notaphplover

Description

@notaphplover

Describe your feature request

Given a vector of regular expressions, I'd like to match all of then in a simultaneously obtaining an array of matches with capture groups.

use regex::RegexSet;

let set = RegexSet::new(&[
    r"\w+",
    r"\d+",
    r"\pL+",
    r"foo",
    r"bar",
    r"barfoo",
    r"foobar",
]).unwrap();

// Iterate over and collect all of the matches.
let matches: Vec<_> = set.matches_and_captures("foobar").into_iter().collect();
assert_eq!(matches, vec![<Captures-0>, 2, 3, 4, 6]);

Where Captures-i represents an object with an index (or similar name) with value i and a captures (or similar name) value with an Option with captures for the regex at index i.

Of course, matches_and_captures is just an example of name for this feature at RegexSet.

Motivation

WASM and wasm-pack in addition to this feature would allow us to build a routing algorithm faster than find-my-way algorithm, the current Fastify routing algorithm, which is the fastest routing algorithm in the NodeJs ecosytem.

I'm open to contribute to this repo in order to achieve this feature and avoid unnecesary forks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions