feat: add regex
This commit is contained in:
18
__regex/hyperscan/src/main.rs
Normal file
18
__regex/hyperscan/src/main.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use hyperscan::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let pattern = pattern! {"test"; CASELESS | SOM_LEFTMOST};
|
||||
let db: BlockDatabase = pattern.build().unwrap();
|
||||
let scratch = db.alloc_scratch().unwrap();
|
||||
let mut matches = vec![];
|
||||
|
||||
db.scan("some test data", &scratch, |id, from, to, _flags| {
|
||||
println!("found pattern #{} @ [{}, {})", id, from, to);
|
||||
|
||||
matches.push(from..to);
|
||||
|
||||
Matching::Continue
|
||||
}).unwrap();
|
||||
|
||||
assert_eq!(matches, vec![5..9]);
|
||||
}
|
||||
Reference in New Issue
Block a user