// 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"(?ms)(ABC-\d+,)(.*?(?=^ABC|\z))").unwrap();
let string = "ABC-1,01/01/1974,X1,Y1,Z1,\"RANDOM SINLGE LINE TEXT 1\",
ABC-2,01/01/1974,X2,Y2,Z2,\"THIS IS
A RANDOM
MULTI LINE
TEXT 2\",
ABC-3,01/01/1974,X3,Y3,Z3,\"THIS IS
ANOTHER RANDOM
MULTI LINE TEXT\",";
// 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/