// 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)href="(\w[^"]+\/pdf4v\/\w[^"]+)"#).unwrap();
let string = "<ul>
<li><a href=\"#\" id=\"fav\" onclick=\"return favoritesadd(8094,'fav.png','removefav.png');\"><img id=\"fav8094\" src=\"fav.png\" alt=\"\" border=\"0\" /> <span id=\"fav8094\">ADD TO WISHLIST</span></a></li>
<li class=\"sixcol right\"><a href=\"https://documents.domain.com/content/updates/year18/jv/folder01/pdf/pdf8094.zip?exp=1567791065&hsh=5a49e7d4828603beddbfb058a1535f5e&dl=att&filename=pdf-00008094-16.pdf\" class=\"tcenter\"><img src=\"pdf.png\" class=\"icon\" align=\"left\" />16<br /><span class=\"small\">download pdf</span></a></li>
<li class=\"sixcol\"><a href=\"https://documents.domain.com/content/updates/year18/jv/folder01/pdf4v/pdf4v8094.zip?exp=1567791065&hsh=246a7702296f7db363ecaa1746a8815a&dl=att&filename=pdf-00008094-40.pdf\" class=\"tcenter\"><img src=\"pdf.png\" class=\"icon\" align=\"left\" />40<br /><span class=\"small\">download pdf</span></a></li>
<div class=\"clear\"></div>
<li><a href=\"/details.php?id=8094&num=1&ss=1\" onclick=\"$.open();return false;\"><img src=\"/images/details.png\" class=\"center\" />Details</a></li>
</ul>";
// 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/