// 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#"(?s)<ul.*?">(.*?)<\/ul>"#).unwrap();
let string = "<div id=\"outer\">
<ul id=\"ancTop\">
<li style=\"font-family: arial; font-size: 9pt;\">
<div style=\"overflow: hidden; width: 690px; height: 17px;\">
<a href=\"#\">
A90 - Lorem Ipsum
</a>
</div>
</li>
<li style=\"font-family: arial; font-size: 9pt;\">
<div style=\"overflow: hidden; width: 690px; height: 17px;\">
<a href=\"#\">
A85 - Lorem Ipsum
</a>
</div>
</li>
</ul>
</div>";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/