

Getting this right seems possible,īut is tricky since the match state needs to be propagated through multiple

Semantics of Aho-Corasick (without additional search time overhead) such that Non-POSIX) will report Samwise as a match, but the standard Aho-CorasickĪlgorithm modified for reporting non-overlapping matches will report Sam.Ī novel contribution of this library is the ability to change the match Most regex engines (that are Perl-like, or For example, consider matching the regex Samwise|SamĪgainst the text Samwise.

This doesn't always work in the expected way, since it will report matches as Unfortunately the "obvious" way to modify the Aho-Corasick algorithm to do The case of finding all successive non-overlapping matches like you might with In many cases, overlapping matches may not be desired, such as

Structured such that it reports all possible matches, even when they overlap In the textbook description of Aho-Corasick, its formulation is typically to_vec(), wtr) Example: finding the leftmost first match as_bytes(), & mut wtr, replace_with)Īssert_eq!( b"The slow grey sloth.". All you need to // do is supply a pair of `std::io::Read` and `std::io::Write` implementations. In a real example, these might be `std::fs::File`s instead.
