// 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)[^:]*: Input Traffic(.*)").unwrap();
let string = "MDS9706-1: Input Traffic fc1/12 - HOST12-HBA2
MDS9999-1: Input Traffic fc1/12 - HOST12-HBA2
abc-123: Input Traffic fc1/12 - HOST12-HBA2
1: Input Traffic fc1/12 - HOST12-HBA2
This will match: Input Traffic fc1/12 - HOST12-HBA2
This_wont_be_matched Input Traffic fc1/12 - HOST12-HBA2";
// 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/