// 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"(?mi)^Case title: +(?<caseTitle>.*\S) *\n+Client: +(?<client>.*?\S) *\n+Origin: +(?<origin>.*?\S) *\n+Contact: +(?<contact>.*?\S) *\n+DSM: +(?<dsm>.*?) *\n+CSM: +(?<csm>.*?\S) *\n+Assigned To: +(?<assignedTo>.*?\S) *\n+Due Date: +(?<dueDate>.*?\S) *\n+Description: +(?<desc>.*?\S) *$").unwrap();
let string = "Case title: Sample Test case 9
Client: 8688211
Origin: Email
Contact: testing@me.com
DSM: testContact1
CSM: testContact1
Assigned To: testing@me.com
Due Date: 06/28/2023
Description: Sample description 9
Case title: Sample Test case 9
Client: 8688211
Origin: Email
Contact: testing@me.com
DSM: testContact1
CSM: testContact1
Assigned To: testing@me.com
Due Date: 06/28/2023
Description: Sample description 9 ";
// 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/