// 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#"(?i)<a href="([^"]+)" target="([^"]+)" rel="([^"]+)" title="([^"]+)">([^<]+)<\/a>"#).unwrap();
let string = "test <a href=\"http://www.un-site.com/page.html\" target=\"_blank\" rel=\"nofollow\" title=\"Mon site\">Cliquez sur ce lien</a> test
test <a href=\"http://www.un-site2.com/page2.html\" target=\"_new\" rel=\"nofollow\" title=\"Mon site2\">Cliquez sur ce lien 2</a> test
test <a href=\"http://www.un-site3.com/page3.html\" target=\"_parent\" rel=\"nofollow\" title=\"Mon site3\">Cliquez sur ce lien 3</a> test
test <a href=\"http://www.un-site4.com/page4.html\" target=\"frame\" rel=\"nofollow\" title=\"Mon site4\">Cliquez sur ce lien 4</a> test";
// 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/