multimatch
Search text for many patterns at once. Literals go through Aho-Corasick (one pass, any number of patterns). Regexes run in parallel. Optional Hyperscan SIMD backend for 3-5x throughput.
use ;
let patterns = builder
.add_literal
.add_literal
.add_regex
.build
.unwrap;
let matches = patterns.scan;
for m in &matches
Why not just use aho-corasick + regex directly?
You can. multimatch wraps them into a single interface so you don't juggle two APIs. It also:
- Separates case-sensitive and case-insensitive literals into distinct automata (faster than one mixed automaton)
- Pre-allocates result buffers based on pattern count
- Provides the
Scannertrait so you can swap backends without changing calling code - Adds convenience constructors:
from_literals(&["a", "b", "c"])builds a pattern set in one line
If Hyperscan is available and you enable the simd feature, the same code runs 3-5x faster with zero API changes.
The Scanner trait
Any pattern matching backend can implement Scanner:
use ;
;
Convenience
// Build from a list of strings
let ps = from_literals.unwrap;
// Build from regex patterns
let ps = from_regexes.unwrap;
SIMD acceleration
Enable Hyperscan (requires libhs installed):
[]
= { = "0.1", = ["simd"] }
Same API, faster execution. Falls back to Aho-Corasick + regex on systems without Hyperscan.
Contributing
Pull requests are welcome. There is no such thing as a perfect crate. If you find a bug, a better API, or just a rough edge, open a PR. We review quickly.
License
MIT. Copyright 2026 CORUM COLLECTIVE LLC.