// 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)\* LIST \((?<Markers>.*)\) \"\/\" (?<folder>.*?)$"#).unwrap();
let string = "* LIST (\\HasChildren) \"/\" INBOX/Arkabit
* LIST (\\HasNoChildren) \"/\" \"INBOX/Arkabit/Flora (SAP)\"
* LIST (\\HasNoChildren) \"/\" INBOX/BRW
* LIST (\\HasNoChildren) \"/\" INBOX/Chiptronics
* LIST (\\HasNoChildren) \"/\" INBOX/CRMB1.COM
* LIST (\\Marked \\HasChildren) \"/\" INBOX/CVA
* LIST (\\HasNoChildren) \"/\" INBOX/CVA/Contabilista
* LIST (\\HasNoChildren) \"/\" INBOX/CVA/Maxflex
* LIST (\\HasNoChildren) \"/\" INBOX/Decorlux
* LIST (\\HasNoChildren) \"/\" INBOX/Fabiano
* LIST (\\HasNoChildren) \"/\" INBOX/Fabielle
* LIST (\\HasNoChildren) \"/\" INBOX/Gamma
* LIST (\\HasNoChildren) \"/\" INBOX/Integrate
* LIST (\\HasNoChildren) \"/\" INBOX/Kelli
* LIST (\\HasNoChildren) \"/\" INBOX/Laborclin
* LIST (\\HasNoChildren) \"/\" INBOX/Macrosul
* LIST (\\HasChildren) \"/\" INBOX/MadeiraMadeira
* LIST (\\HasNoChildren) \"/\" INBOX/MadeiraMadeira/BRW
* LIST (\\HasNoChildren) \"/\" INBOX/MadeiraMadeira/Eglo
* LIST (\\HasNoChildren) \"/\" \"INBOX/MadeiraMadeira/Full Fit\"
* LIST (\\HasNoChildren) \"/\" \"INBOX/MadeiraMadeira/Glass Mosaic\"
* LIST (\\Marked \\HasNoChildren) \"/\" INBOX/MadeiraMadeira/Luciin
* LIST (\\HasNoChildren) \"/\" INBOX/MadeiraMadeira/Rojemac
* LIST (\\HasNoChildren) \"/\" \"INBOX/Mercado do Alarme\"
* LIST (\\Marked \\HasChildren) \"/\" INBOX/Stuff
* LIST (\\HasNoChildren) \"/\" INBOX/Stuff/Importado
* LIST (\\Marked \\HasNoChildren) \"/\" INBOX/Stuff/Ita&APo-
* LIST (\\Marked \\HasNoChildren) \"/\" INBOX/Stuff/Literal
* LIST (\\HasChildren) \"/\" INBOX/Stuff/News
* LIST (\\HasNoChildren) \"/\" INBOX/Stuff/News/Linkedin
* LIST (\\HasNoChildren) \"/\" INBOX/Stuff/News/Microsoft
* LIST (\\HasNoChildren) \"/\" INBOX/Stuff/News/SAP
* LIST (\\Marked \\HasNoChildren) \"/\" INBOX/Stuff/Postman
* LIST (\\HasChildren) \"/\" INBOX/Stuff/PrimaERP
* LIST (\\HasNoChildren) \"/\" INBOX/Stuff/PrimaERP/Faturas
* LIST (\\Marked \\HasNoChildren) \"/\" INBOX/Stuff/VSOnline
* LIST (\\HasNoChildren) \"/\" \"INBOX/Suporte | CRMSAP\"
* LIST (\\HasNoChildren) \"/\" INBOX/Umbler
$ OK LIST completed.
";
// 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/