// 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)^(\+ *|- *)?((?!0+)\d*?|(?!0{2,})\d*?\.(?!0+)\d*?)('|")$|^(\+ *|- *)? *(?!0+)\d+?' *-? *(\d+?|\d*?\.\d*?)"$|^((\+ *|- *)?((?!0+)|0 )\d*? *(?!0+)\d+?\/(?!0+)\d+?('|"))$"#).unwrap();
let string = " -
+
- x 20'-4\"
+ 20'
- 20'
20'3\"
20'-3\"
20' - 40\"
-20'-20\"
20'00\"
20.45\"
20.45'
00.45'
00.45\"
00\"
00'
+20' - 0.45\"
20' - .45\"
.20'-4\"
0.30'-4\"
20'
20'P
20\"
20\"P
0.20'
.20'
a'
b\"
- 20 1/2'
+ 20 22/128\"
20 0/2\"
20 00/12'
-1/2\"
+ 1/2'
0/2\"
00/22\"
+ 01/2\"
23 00/30'
23 12/03'
23 02/20\"
0 2/3'
00 2/3'
- 11 2/3'
2 22'
2 22/03'
2 3/2
23 00/30
23 12/03
23 02/20
23/34\"
23/23.4\"
asf sf\"
";
// 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/