Andrew Gallant 94d0ad486e Add regex sets.
Regex sets permit matching multiple (possibly overlapping) regular
expressions in a single scan of the search text. This adds a few new
types, with `RegexSet` being the primary one.

All matching engines support regex sets, including the lazy DFA.

This commit also refactors a lot of the code around handling captures
into a central `Search`, which now also includes a set of matches that
is used by regex sets to determine which regex has matched.

We also merged the `Program` and `Insts` type, which were split up when
adding the lazy DFA, but the code seemed more complicated because of it.

Closes #156.
2016-02-21 20:52:07 -05:00

20 lines
385 B
Rust

extern crate regex;
use regex::RegexSet;
fn main() {
let res = &[
"abc",
"xyzz",
"^[ga-fh-z]+$",
];
let text = "abcggggggggxyz";
let set = RegexSet::new(res).unwrap();
println!("{:?}", set);
let m = set.is_match("abcggggggggxyz");
println!("match? {:?}", m);
for mi in set.matches(text) {
println!("{:?}", mi);
}
}