// 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)^record(?<id>\d+),[0-9\#\$\%\-\+\,]+,(?<name>\w+),[\D\,]+,(?<PostalCode>\d+),[0-9\#\$\%\-\+\,]+,(?<Status>(true|false)),End$").unwrap();
let string = "record18,$65535,sisoog,do,5463213,33436,12,18,-17,+16,78,trUe,End
record15,#15,25,45,sisoog,s,is,oog,5463213,6,-7,78,33-43,True,End
record16,55,-35,sisoog,End,use,wait,546365213,#88,15,5485,False,End
record17,15,-45,351,sisoog,do,wait,smit,5463213,33-436,faLse,End
record17,15,-45,351,sisoog,do,smit,5463213,3436,End";
// 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/