// 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".").unwrap();
let string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt pellentesque ex tempor porta. Ut <a href=\"http://molestielectus.com\">molestie lectus</a> egestas lectus ornare, eu pellentesque ante posuere.
Nunc volutpat non tellus tincidunt tincidunt. Aenean scelerisque sit amet felis eget vestibulum. <a title=\"Fusce blandit\" href=\"https://www.fusceblandit.com\">Fusce blandit</a> bibendum ligula, et viverra nunc faucibus in. Etiam hendrerit in turpis eget varius.
Phasellus pellentesque porttitor laoreet. Curabitur pharetra cursus sapien, non gravida libero <a href=\"mailto:feugiat@fermentum.com\">feugiat fermentum</a>. Nam bibendum auctor condimentum. Integer ut rhoncus odio, facilisis aliquam orci.
Ut placerat nisi urna, eget ultricies enim gravida ac. Praesent sed aliquam urna. Etiam ornare purus a sapien <a href='//vulputatemattis.com'>vulputate mattis</a>.
Morbi tempor imperdiet risus, quis tristique nunc varius et. Praesent elementum at arcu nec malesuada. <a href=\"//integerporta.com\" title=\"Integer porta\">Integer porta</a> lorem non commodo eleifend. Curabitur ut risus non libero volutpat posuere.";
// 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/