// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)^\w+(\s\w&\w)").unwrap();
let string = "Employee Communications & Engagement, WB
SVP of Global Insights & Analytics, WB
SVP of Nonfiction, HBO Max
VP of Talent Relations and Development, TCM
Global Franchise Management, DC
WB Technology Group
President, EMEA & APAC
SVP & CFO, EMEA & APAC
Director, Service Delivery
SVP for Sales and Client Partnerships, Legacy Turner
Technical Director, WarnerMedia
Dir. of Brand Distribution, WarnerMedia
Dir. Strategic & Consumer Insights, Turner Sports
Manager for Digital Asset & Photo Library, Brand Experience
Creative Manager for Creative Services, Cartoon Network
// 2 words
Cincinnati Bearcats
Miami (FL) Hurricanes
Miami (OH) Redhawks
// three words
South Florida Bulls // 2.1
Saint Joseph's Hawks
Duke Blue Devils // 1.2
UNLV Runnin' Rebels // with apostrophe
// 4 words
North Carolina Tar Heels
Notre Dame Fighting Irish
St John's Red Storm
Florida A&M Rattlers
William & Mary Tribe
St Francis (PA) Red Flash
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/