// 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)typedef enum\s*{([^;*]+)}rba_EcuSecu").unwrap();
let string = "typedef enum
{
CONTEXT_0 = 0,
CONTEXT_1 = 1,
CONTEXT_2 = 2,
CONTEXT_3 = 7,
}aes_context_e;
typedef enum
{
CIPHER_MATCH_E = 0,
CIPHER_NOT_MATCHED_E = 1,
CIPHER_MATCH_NOT_POSSIBLE_E = 3,
CIPHER_MATCHED_TAG_NOT_MATCHED = 5,
CIPHER_NOT_MATCHED_TAG_MATCHED = 6,
}rba_EcuSecu_AES_CipherChk_e;";
// 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/