English | 简体中文 |
A high-performance Rust crate for multi-pattern string matching, validation, filtering, and replacement.
find_all
validate
filter
replace
rayon
find_all_batch
find_all_layered
find_all_streaming
Add to your Cargo.toml
:
[dependencies]
sensitive-rs = "0.5.0"
use sensitive_rs::Filter;
fn main() {
let mut filter = Filter::new();
filter.add_words(&["rust", "filter", "敏感词"]);
let text = "hello rust, this is a filter demo 包含敏感词";
let found = filter.find_all(text);
println!("Found: {:?}", found);
let cleaned = filter.replace(text, '*');
println!("Cleaned: {}", cleaned);
}
Batch processing:
let texts = vec!["text1", "text2"];
let results = filter.find_all_batch( & texts);
Layered matching:
let layered = filter.find_all_layered("some long text");
Streaming large files:
use std::fs::File;
use std::io::BufReader;
let reader = BufReader::new(File::open("large.txt") ? );
let stream_results = filter.find_all_streaming(reader) ?;
For detailed documentation, please refer to Documentation.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 or MIT license, shall be dual licensed as above, without any additional terms or conditions.