use regex::Regex; fn main() { let re = Regex::new(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b").unwrap(); let text = "Contact us at info@rust-lang.org or support@rust-lang.org."; for cap in re.captures_iter(text) { println!("Found email: {}", &cap[0]); } }