// 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)(?<=src=").*?(?=[\?"])"#).unwrap();
let string = "<iframe src=\"http://www.youtube.com/embed/NM51qOpwcIM?modestbranding=1;rel=0;showinfo=0;autoplay=0;autohide=1;yt:stretch=16:9;wmode=transparent;?wmode=transparent\" allowfullscreen=\"\" style=\"width: 640px; height: 361.057px;\" frameborder=\"0\"></iframe>
<iframe src=\"https://www.youtube.com/embed/VASywEuqFd8?feature=oembed\" allowfullscreen=\"\" width=\"660\" height=\"371\" frameborder=\"0\"></iframe>
";
// 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/