Boyer-Moore-MagicLen
This crate can be used to search substrings in a string or search any sub-sequences in any sequence by using boyer-moore-magiclen (which is sometimes faster than boyer-moore and boyer-moore-horspool).
Usage
For binary data and UTF-8 data, use the BMByte
struct. For character sequences, use the BMCharacter
struct (however it is much slower than BMByte
).
Every BMXXX
has a from
associated function to create the instance by a search pattern (the needle).
For example,
extern crate boyer_moore_magiclen;
use BMByte;
let bmb = from.unwrap;
Now, we can search any binary data or UTF-8 data for the pattern oocoo
.
There are two search modes and two search directions. The first mode is called full text search, which finds the positions of the matched sub-sequences including the overlapping ones.
extern crate boyer_moore_magiclen;
use BMByte;
let bmb = from.unwrap;
assert_eq!;
The other mode is called normal text search, which finds the positions of the matched sub-sequences excluding the overlapping ones.
extern crate boyer_moore_magiclen;
use BMByte;
let bmb = from.unwrap;
assert_eq!;
The search direction can be from the head (searching forward, find_xxx
) or from the tail (searching backward, rfind_xxx
).
extern crate boyer_moore_magiclen;
use BMByte;
let bmb = from.unwrap;
assert_eq!;
To search all results at a time, use the find_all_in
, rfind_all_in
, find_full_all_in
or rfind_full_all_in
method.
extern crate boyer_moore_magiclen;
use BMByte;
let bmb = from.unwrap;
assert_eq!;
Benchmark
or
Crates.io
https://crates.io/crates/boyer-moore-magiclen
Documentation
https://docs.rs/boyer-moore-magiclen