// 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"(?sx)\#\#\#\#\#\#PROJECT\s+Name:\s+(?P<PROJECT_NAME>.+?)\#\#\#\#\#\#
.+?
(?P<OVERLOAD>OVERLOAD\(%\)(?:\s+\d+\.\d+){4}).+?
(?P<LOSS_OF_LOAD>LOSS\s+OF\s+LOAD\s+\(M\)(?:\s+\d+\.\d+){4})").unwrap();
let string = "######PROJECT Name: ABCD######
foo
bar
baz
OVERLOAD(%) 0.3361 10.0 3.4 2.49 1
LOSS OF LOAD (M) 10.5780 10.0 105.8 14026.67 11
######PROJECT Name: ABCD2######
foo
bar
baz
OVERLOAD(%) 0.3361 10.0 3.4 2.49 1
LOSS OF LOAD (M) 10.5780 10.0 105.8 14026.67 11";
// 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/