// 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"\-(((ae|as)|(ge|et|xe)\-\d\/\d\/)\d+(:\d){0,1}\.\d+)").unwrap();
let string = "policerdrop-bs.[lim2m-xe-0/0/1.10106-inet-i]
policerdrop-bs.[lim256k-ge-2/0/0.159-inet-i]
policerdrop-bs.[lim256k-ae2.159-inet-i]
policerdrop-bs.[lim2m-xe-0/0/1:0.10106-inet-i]
policerdrop-bs.[limbw-1m-xe-1/0/0.6027-inet-i]";
// 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/