// 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"(?mi)#(').*(')").unwrap();
let string = "#'The universe is big, it's vast and complicated, and ridiculous and sometimes, very rarely, impossible things just happen and we call them miracles.'
'I am and always will be the optimist. The hoper of far-flung hopes and the dreamer of improbable dreams.'
#'No, hold on. Sorry, that's the 'The Lion King'.'
#'What's the point in two hearts if you can't be a bit forgiving now and then?'
'You know that in 900 years in time and space I've never met anyone who wasn't important before.'
#'You want weapons? We're in a library! Books! Best weapons in the world!'";
// 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/