#![allow(dead_code)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #[macro_use] mod utils; use regex::Regex; fn main() { let s:&'static str = "Four score and seven years ago..."; println!("Match 1: {}", utils::regex_search(Regex::new(r"s.*e").unwrap(), s)); println!("Match 2: {}", utils::regex_search(Regex::new(r"\bs.*e\b").unwrap(), s)); println!("Match 3: {}", utils::regex_search(Regex::new(r"s...e").unwrap(), s)); println!("Match 4: {}", utils::regex_search(Regex::new(r"b.d").unwrap(), s)); let mut subgroups:Vec = utils::regex_find_first(Regex::new(r"(\w+)\s*(\w+)").unwrap(), s); println!("Find First (with subgroups): {}", list_to_string!(subgroups)); subgroups = utils::regex_find_first(Regex::new(r"bad match").unwrap(), s); println!("Find First (bad match): {}", list_to_string!(subgroups)); let mut matches:Vec = utils::regex_find_all(Regex::new(r"\w+").unwrap(), s); println!("Find All: (matches only){}", list_to_string!(matches)); matches = utils::regex_find_all(Regex::new(r"bad match").unwrap(), s); println!("Find All (bad match): {}", list_to_string!(matches)); }