// 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#"(?si)<div class="(.*?) video-item">(.*?)href="([^"]*)"(.*?)data-get-thumbs-url="([^"]*)"(.*?)alt="([^"]*)"(.*?)src='([^']*)'(.*?)<div class="timer hidden-xs">(\s*)<p>([0-9]*)(.*?)<\/p><\/div>(.*?)<div class="description">(\s*)<p>(.*?)<\/p>(.*?)<p class="title-video">(.*?)<\/p>(.*?)<div class="infos-video">(.*?)<p>Le ([0-9][0-9])\/([0-9][0-9])\/([0-9][0-9][0-9][0-9])<\/p>(\s*)<p>([0-9 ]*?)vues<\/p>(.*?)<\/div>(.*?)<div class="cat-video">(\s*)(.*?)(\s*)<\/div>(\s*?)<\/div>"#).unwrap();
let string = "
<div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">
<a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1983/sandrine-teste-la-double.html\">
<div class=\"thumb-video\">
<img class=\"videoThumb\"
data-get-thumbs-url=\"/video/1983/thumbnails_262x196.json\"
alt=\"Double pénétration, Double vaginale, Sodomie\"
src='http://m.tv2.cdn.jetm-tech.net/cache/4a/c5/4ac5ff7ae42612bfc68139740700ea0c.jpg'
/>
<div class=\"timer hidden-xs\"> <p>47 min</p></div>
<div class=\"description\">
<p>Notre équipe retrouve Sandrine devant le château de Blois pour constater, une fois de plus, que cette timide historienne de 31ans est une sacrée chaudasse !
…</p>
</div>
</div>
<p class=\"title-video\"> Sandrine teste la double !</p>
<div class=\"infos-video\">
<p>Le 12/10/2015</p>
<p>1 876 156 vues</p>
</div>
</a>
<div class=\"cat-video\">
<p>Catégories : <a href=\"/tag/1/double-penetration.html\">Double pénétration</a>, <a href=\"/tag/2/double-vaginale.html\">Double vaginale</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a></p>
</div>
</div>
<div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">
<a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1982/soizic-passe-un-entretien-dembauche.html\">
<div class=\"thumb-video\">
<img class=\"videoThumb\"
data-get-thumbs-url=\"/video/1982/thumbnails_262x196.json\"
alt=\"Cougar, Scénario, Sodomie\"
src='http://m.tv2.cdn.jetm-tech.net/cache/cc/e5/cce55a7502d51aaefc049ee83334653c.jpg'
/>
<div class=\"timer hidden-xs\"> <p>30 min</p></div>
<div class=\"description\">
<p>Quand Soizic, 40ans, de Saint-Malo, et l'ami Rick se font un petit plan un brin pervers...
Pour voir ses vidéos, mettez Soizic dans la recherche.
Parlez en …</p>
</div>
</div>
<p class=\"title-video\"> Soizic passe un entretien d'embauche !</p>
<div class=\"infos-video\">
<p>Le 11/10/2015</p>
<p>1 882 538 vues</p>
</div>
</a>
<div class=\"cat-video\">
<p>Catégories : <a href=\"/tag/23/cougar.html\">Cougar</a>, <a href=\"/tag/56/scenario.html\">Scénario</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a></p>
</div>
</div>
<div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">
<a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1981/lola-se-libere.html\">
<div class=\"thumb-video\">
<img class=\"videoThumb\"
data-get-thumbs-url=\"/video/1981/thumbnails_262x196.json\"
alt=\"Double pénétration, Sodomie, Trio HHF\"
src='http://m.tv2.cdn.jetm-tech.net/cache/f3/5b/f35b23b16f81588dda16702cec5ef284.jpg'
/>
<div class=\"timer hidden-xs\"> <p>42 min</p></div>
<div class=\"description\">
<p>Sa première vidéo a eu de telles vertus thérapeutiques que Lola surmonte désormais tous ses complexes et va même jusqu'à nous entraîner chez un de ses nouveaux…</p>
</div>
</div>
<p class=\"title-video\"> Lola se libère !</p>
<div class=\"infos-video\">
<p>Le 10/10/2015</p>
<p>1 717 096 vues</p>
</div>
</a>
<div class=\"cat-video\">
<p>Catégories : <a href=\"/tag/1/double-penetration.html\">Double pénétration</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a>, <a href=\"/tag/21/trio-hhf.html\">Trio HHF</a></p>
</div>
</div>
";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/