// 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)(?'comando'\w+)(?'valor'\(.*?\))").unwrap();
let string = "
search(objeto(atributo.subatributo)).equals(1).and(search(objeto2(atributo2)).gte(1))
group(objeto(atributo)).equals(1).orderby(atributo.field)
objeto(atributo).equals(1)
search(objeto(attr)).and(seach(objeto(attr2)).and(search(objeto(attr3)";
// 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/