// 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#"(\bhref="(.*?)\b")(?!.*\1)?"#).unwrap();
let string = " <div>
<a href=\"showthread.php?t=5239160\" id=\"thread_title_5239160\">программа для точного определения местоположения любого гаджета</a>
<span class=\"smallfont\" style=\"white-space:nowrap\">(<img class=\"inlineimg\" src=\"https://static.kharkovforum.com/images/misc/multipage.gif\" alt=\"перейти на страницу\" border=\"0\" /> <a href=\"showthread.php?t=5239160\">1</a> <a href=\"showthread.php?t=5239160&page=2\">2</a>)</span>
</div>
<div class=\"smallfont\">
<span style=\"cursor:pointer\" onclick=\"window.open('member.php?u=502041', '_self')\">I-am</span>
</div>
";
// 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/