// 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)\b(?:in|and|is)\s+((?:.(?!\b(?:in|and|is)\b))*(?:HomeStay|Luxury)(?:.(?!\b(?:in|and|is)\b))*)(?!.*(?:HomeStay|Luxury).*)").unwrap();
let string = "Hello, tonight I'm in the town of Trenton in Hotel HomeStay [123] in New Jersey and I will be staying in Hotel HomeStay [123] and I have no money. Actually, I'm wealthier than this guy outside, I will be staying in Hotel HomeStay [123] and I have tons of money. in Hotelin HomeStay [123in]. HomeStay and never gonna give you up, never gonna make you cry. This is Luxury, and a cheeseburger.
";
// 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/