// 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"(?mi)\$(?P<type>(?:v|a|s))?(?P<prop>(?:lang|lang2|lang3|language|codec|format|ch|channels|res|resolution))(?:(?:_(?P<num>\d+))|(?:_(?P<lang>[^_0-9\$\n]+)(?:_(?P<num2>\d+))?))?\$").unwrap();
let string = "$alang$
$alang_0$
$acodec$
$acodec_0$
$acodec_jp$
$acodec_jp_0$
$aformat$
$aformat_0$
$aformat_jp$
$aformat_jp_0$
$ach$
$ach_0$
$ach_jp$
$ach_jp_0$
$achannels$
$achannels_0$
$achannels_jp$
$achannels_jp_0$
$codec$
$res$ $vformat$ $aformat_jp$ $ach_0$";
// 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/