// 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"(?s)(TEST_CASE_NAME.*?:(.*?)\n.*?PRIORITY.*?:(?!P3)(\w\d).*?=cut)").unwrap();
let string = "=head2 Gen_001
TEST_CASE_NAME :GEN_001
PRIORITY :P0
RELEASE_INTRODUCED :7.4 AUTOMATED :YES
STEP_NAME : step1
STEP_DESC :Example desc for understanding STEP_RESULT :Example result for understanding
=cut
=head2 Gen_003
TEST_CASE_NAME :GEN_003
PRIORITY :P1
RELEASE_INTRODUCED :7.4 AUTOMATED :NO
STEP_NAME : step1
STEP_DESC :Example desc for understanding second testcase
STEP_RESULT :Example result for understanding second testcase
=cut
=head2 Gen_004
TEST_CASE_NAME :GEN_004
PRIORITY :P3
RELEASE_INTRODUCED :7.4 AUTOMATED :NO
STEP_NAME : step1
STEP_DESC :Example desc for understanding third testcase
STEP_RESULT :Example result for understanding third testcase
=cut";
// 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/