// 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"(Order[0-9])(?!.*\1)").unwrap();
let string = "<ctx>
<PostCode>XXXXXX</PostCode>
<Title1>Mr</Title1>
<Name>John</Name>
<Order1>£100.00</Order1>
<Order2>£100.01</Order2>
<Order3>£100.01</Order3>
<Order4>£100.01</Order4>
<Order5>£100.01</Order5>
<Order6>£100.01</Order6>
<Order7>£100.01</Order7>
<Order8>£100.01</Order8>
<Order9>£100.01</Order9>
<Order10>£100.01</Order10>
<Order11>£100.01</Order11>
<Order50>£100.01</Order50>
<Date>10/10/2010</Date>
</ctx>";
// 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/