// 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"(?mix)(?>^|\s+|\W)
(
(?>[a-z]\d*|\d+[a-z]?
(?>\(
([a-z]\d*|\d+[a-z]?)
\)[a-z]?
)?)
(?>\.(?>[a-z]|\d+[a-z]?))*
|
(?>M{0,4}(?>CM|CD|D?C{0,3})(?>XC|XL|L?X{0,3})(?>IX|IV|V?I{0,3}))
)
(?>\s+|\W|$)").unwrap();
let string = "Appendix 1
6.48
CP 198
3.2.4 G
2
1.
B.
Appendix 1
Annex A
4A.10.1 and 4A.15
4A.21.10
Annex ii
A)
SECTION IV
52.19A
PRACTICE DIRECTION 83—
RSC ORDER 109
Rule 4
ADMINISTRATIVE COURT GUIDANCE
PRACTICE STATEMENT
THE PROTOCOL
C.6
Draft modules
CIS11:
Appendix 13(2)e
2002 no.
(a)
L7.3.1.R
(iii)
";
// 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/