// 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#"(?i)<div[^>]*data-oembed-url=["'](.*?)["'].*?>"#).unwrap();
let string = "<p><strong>Integer</strong> ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a <em>libero</em>. In <u>auctor</u> lobortis lacus. Curabitur suscipit suscipit tellus. Fusce convallis metus id felis luctus adipiscing.</p> <div data-oembed-url=\"https://www.youtube.com/watch?v=WwHy2hotU6c\" data-> <div style=\"left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;\"><iframe allowfullscreen=\"true\" frameborder=\"0\" mozallowfullscreen=\"true\" src=\"https://www.youtube.com/embed/WwHy2hotU6c?wmode=transparent&rel=0&autohide=1&showinfo=0&enablejsapi=1\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\" webkitallowfullscreen=\"true\"></iframe></div> </div> <ol> <li>Um</li> <li>Dois</li> <li>Três</li> </ol> <div data-oembed-url=\"http://pt.slideshare.net/josephj/from-hacker-to-programmer-w-webpack-babel-and-react\"> <div style=\"left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 83.5282%;\"><iframe allowfullscreen=\"true\" frameborder=\"0\" mozallowfullscreen=\"true\" src=\"https://www.slideshare.net/slideshow/embed_code/key/4guX8biZafHvI7\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\" webkitallowfullscreen=\"true\"></iframe></div> </div> <ul> <li>Primeiro</li> <li>Segundo</li> <li>Terceiro</li> </ul> <p>In consectetuer turpis ut velit. Duis lobortis massa imperdiet quam. Curabitur at lacus ac velit ornare lobortis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam.</p> <p>Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Quisque rutrum. Curabitur blandit mollis lacus. Duis leo. Suspendisse potenti.</p>";
// 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/