// 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)<li>([a-zA-Z]+)<br \/>([a-zA-Z]+)<\/li>").unwrap();
let string = "<div class='post-header'>
<div class='post-header-line-1'></div>
</div>
<div class='post-body entry-content' id='post-body-210098160524748093' itemprop='articleBody'>
<div class=\"separator\" style=\"clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;\">
<br /></div>
<br />
<br />
<ul>
<li>Name<br />Location</li>
<li>Name<br />location</li>
<li>name<br />location</li>
<li>name<br />location</li>
</ul>
<br />
";
// 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/