// 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"(?Us)<\s*?script\s*?([^>]*)\s*?>\s*?(.+)?\s*?<\s*?\/script\s*?>").unwrap();
let string = "< script type=\"text/javascript\" src=\"//vk.com/js/api/openapi.js?65\"> < /script >
<script type=\"text/javascript\" >
VK.init({apiId: 3251711, onlyWidgets: true});
</script>
<script type=\"text/javascript\" src=\"http://keddr.com/wp-content/themes/keddr3-1/js/lite-youtube.js\" ></script>
<script type=\"text/javascript\" src=\"http://keddr.com/wp-content/themes/keddr3-1/js/jquery.complexify.js\" > sfdbb </script>
<script type=\"text/javascript\" >
$(function () {
if (($(\"#pass1\").length 0)) {
$(\"#pass1\").complexify({}, function (valid, complexity) {
if (complexity < 1) {
$('#progress').css({'width': complexity + '%'}).removeClass('progressbarValidGood').addClass('progressbarInvalid');
$('.passAlert').hide();
} else if (complexity > 1 && complexity < 40) {
$('#progress').css({'width': complexity + '%'}).removeClass('progressbarValidGood').addClass('progressbarInvalid');
$('.passAlert.good').hide();
$('.passAlert.bad').fadeIn();
} else if (complexity > 40) {
$('#progress').css({'width': complexity + '%'}).removeClass('progressbarValidGood').addClass('progressbarValid');
$('.passAlert.good').hide();
$('.passAlert.strong').fadeIn();
}
$('#complexity').html(Math.round(complexity) + '%');
});
}
});
</script >";
// 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/