// 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)facebook.*cpc").unwrap();
let string = "free.facebook.com
web.facebook.com
facebook/social/listing
facebook/referral/[facebook][marketplace][house][rent]
facebook/referral/[facebook][marketplace][townhouse][rent]
facebook/cpc/leadgen
facebook/cpc/[facebook][cpc][house][sale]
facebook/cpc/[facebook][cpc][condo][sale]
facebook/cpc/Aus + NZ, Men Over 50s, int Thailand/New Luxury Retirement Village in Southern Thailand
facebook/cpc/[facebook][cpc][townhouse][sale]
facebook/cpc/[facebook][cpc][condo][rent]
facebook/cpc/client->-developer->-leadgen
facebook/cpc/event/
facebook/cpc/[facebook][cpc][land][sale]";
// 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/