// b[aeou]y: This pattern looks for strings that match the following:
// b: The letter "b".
// [aeou]: Any single character that is either "a", "e", "o", or "u".
// y: The letter "y".
use regex::Regex;
fn check_pattern(pattern: &str, text: &str) -> bool {
let re = Regex::new(&format!("(?i){}", pattern)).unwrap();
re.is_match(text)
}
fn main() {
let pattern = "b[aeou]y";
println!("{}", check_pattern(pattern, "A smart Boy")); // b/B o y
println!("{}", check_pattern(pattern, "I want to buy this laptop")); // b u y
println!("{}", check_pattern(pattern, "baay"));
println!("{}", check_pattern(pattern, "baeouy"));
println!("{}", check_pattern(pattern, "baey"));
println!("{}", check_pattern(pattern, "This is beauty"));
println!("{}", check_pattern(pattern, "A programming book"));
}
/*
run:
true
true
false
false
false
false
false
*/