// 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)\[data-testid=([^\]]*?)\](?!.*\[data-testid=.*?\])").unwrap();
let string = "@header;.header-area;.sticky;|@div;.container;|@div;.row;|@div;.col-lg-12;|@nav;.navbar;.navbar-expand-lg;|@div;#navbarSupportedContent;.collapse;.navbar-collapse;|@ul;#nav;.ml-auto;.navbar-nav;|@li;.active;.nav-item;|@a;[data-testid=foo];[href=#service];|
@section;#contact;.contact-area;.pt-115;|@div;.container;|@div;.contact-box;.mt-70;|@div;.row;|@div;.col-lg-8;|@div;.contact-form;|@form;#contact-form;[data-toggle=validator];[method=post];|@div;.row;|@div;.col-lg-12;|@div;.form-group;.single-form;|@button;.main-btn;[type=submit][data-testid=bar];|";
// 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/