// 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)(?=(?=(?'a'[\s\S]*))(?<!'b'<p\b[^>][\s\S]color[\s\S]:[\s\S]black[^>][\s\S]>[\s\S]<span\b[^>][\s\S]>[\s\S])(?<!<span\b[^>][\s\S]color[\s\S]:[\s\S]black[^>][\s\S]>[\s\S])_(?=\k'a'\z)|(?<=(?=x^|(?<!&b))[\s\S]))<code\s*style="background-color:\s*transparent;">"#).unwrap();
let string = "<html>
<p style=\"font-family: "verdana"; font-size: 18px; color: black; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: cyan;\"><span style=\"font-size: 13.5pt; font-family: "Verdana","sans-serif";\"><code style=\"background-color: transparent;\"><b>some text here</b></code></span></p>
<span><span style=\"font-size: 13.5pt; font-family: "Verdana","sans-serif"; background-color: cyan;\"><code style=\"background-color: transparent;\"><b>some text here</b></code></span>
<code style=\"background-color: transparent;\">
<p style=\"font-family: "verdana"; font-size: 18px; color: cyan; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: cyan;\"><span style=\"color: black; font-size: 13.5pt; font-family: "Verdana","sans-serif";\"><code style=\"background-color: transparent;\"><b>some text here</b></code></span></p>
<span><span style=\"font-size: 13.5pt; font-family: "Verdana","sans-serif"; background-color: cyan;\"><code style=\"background-color: transparent;\"><b>some text here</b></code></span>
<p style=\"font-family: "verdana"; font-size: 18px; color: cyan; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: navy;\"><span style=\"font-size: 13.5pt; font-family: "Verdana","sans-serif";\"><code style=\"background-color: transparent;\"><b>some text here</b></code></span></p>
</html>";
// 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/