auto-regex
Rust crate to find a regex rules that best matches a list of string
Example
use auto_regex::infer_regex;
fn main() {
let samples = vec![
"john.doe@gmail.com".to_string(),
"alice.smith@gmail.com".to_string(),
"bob.harris@gmail.com".to_string(),
"badsample".to_string(),
];
let example = "firstname.lastname@gmail.com".to_string();
let regex = infer_regex(example, samples).unwrap();
println!("{}", regex.as_str());
}
Use cases
Used in Inspirateur/SimpleRenamer, a smart file renamer.
It can generally be useful in applications to give Regex power to users who don't know Regex or don't want to bother with it.