// 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"(?im)^(?=.*\bsubject\b)(?=.([\s\S]*)urgent)(?=.([\s\S]*)yahoo\.com).*$").unwrap();
let string = "User-Agent: Microsoft-MacOutlook/10.17.1.190326
Date: Wed, 05 Jun 2019 15:04:21 +0800
Subject: FW: DR OKE DANLDAI PLEASEURGENT
From: Dennis Chng <Dennischng@r-logic.com>
To: helpdesk <helpdesk@iqon-asia.com>,
Raynor Tan <raynor@iqon-asia.com>
Message-ID: <IQON.6059aba563.EF09158E-9BED-4A49-AE31-6851E971014F@r-logic.com>
Thread-Topic: DR OKE DANLDAI PLEASE URGENT
References: <341174902.187389.1559716703368.ref@mail.yahoo.com>
<341174902.187389.1559716703368@mail.yahoo.com>
In-Reply-To: <341174902.187389.1559716703368@mail.yahoo.com>
Mime-version: 1.0";
// 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/