// 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)(<(\w+)[^>]*>)((?!<\2).*)(<\/\2>)").unwrap();
let string = "alpha
<div>
alpha<div>
beta<div>
x < y divided by 4
</div>
</div>
</div>
<div>
<span style=\"font-size: 8pt;\" disabled title=\"data\">
<span>infinite</span>
<?= $record->id ?>
</span>
<div> equal </div>
</div>
<div> sum </div>
When x y and y > 0
<div> Summary</div>
Equation id <?= $equation->id ?>
";
// 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/