// 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)^[LNSE] .*(?:\n(?![LNSE] ).*)?").unwrap();
let string = "L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000
N 066 00 23442 T000185 262.1.00.09 02/25 08:05 00:00:02 A 16630
& 0000 0000
S 067 00 00984 T000134 02/25 08:06 00:00:02 A 61445
& 0000 0000
S 068 00 T000002 29536 02/25 08:05 00:00:36
& 0000 0000 1234567890XXXXXX
E 069 00 T000002 T000185 02/25 08:06 00:00:00
& 0000 0000 1234567890XXXXXX
L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000 ";
// 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/