// 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)"event_type=(?<event_type>\w[a-zA-Z-]+)\D+(?<size>\d*)"#).unwrap();
let string = "{\"event_type\":\"event_type=adsad\",\"size\":\"128844\"}
{\"event_type\":\"event_type=dsadsa\",\"size\":\"388719\"}
{\"event_type\":\"event_type=blue\",\"size\":\"1841504\"}
{\"event_type\":\"event_type=bluecoat\",\"size\":\"221712725587\"}
{\"event_type\":\"event_type=casmdsad\",\"size\":\"12356947232\"}
{\"event_type\":\"event_type=cisco-ddddd\",\"size\":\"1553892585172\"}
{\"event_type\":\"event_type=cisco-edsd\",\"size\":\"42949321020\"}
{\"event_type\":\"event_type=cyberark-dsds\",\"size\":\"77274472\"}";
// 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/