// 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"(?i)(\()|(?:(([udfblrmesxyz])(?:([-i'])|(2))?)|(\[((?:(?:[ud][fb]|[fb][ud])(?:[lr]?)|(?:[fb][lr]|[lr][fb])(?:[ud]?)|(?:[ud][lr]|[lr][ud])(?:[fb]?))|(?:o[24][udfb]|o6[lr]|c[cw][23]|pt[jn]|par|prn))]))|(\)([1-9min'])?)").unwrap();
let string = "face rotations: fblrudf'b'l'r'u'd'fibiliriuidi
axis rotations: xyzx'y'z'xiyizi
pieces: [uf][ub][df][db][fu][bu][fd][bd][fl][fr][bl][br][lf][rf][lb][rb][ur][ul][dr][dl][ru][lu][rd][ld][urf][ufr]...
patterns: [o2u][o2f]...[o4d][o4b]...[o6l][o6r][cc2][cc3][cw2][cw3][par][ptn][ptj][prn]
groups: (rf) (rf)'(rf)n (rf)i (rf)m (rf)3
mixed (and test):
[f'r-abix2]
[r2u]
(r(fr)i[FR])m f";
// 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/