// 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"(?Uis)<\!--\[if\s+lt\s+IE\s+\d][^>]*>(.*)<\!\[endif\]-->").unwrap();
let string = "
rwerwerw
<!--[if lt IE 9]>
<script src=\"https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js\"></script>
<script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>
<![endif]-->
rwerwerwerwe
<script type=\"text/javascript\">
jQuery(window).on('load', function() {
new JCaption('img.caption');
});
if (typeof RokBoxSettings == 'undefined') RokBoxSettings = {pc: '100'};
jQuery(document).ready(function()
{
jQuery('.hasTooltip').tooltip({\"html\": true,\"container\": \"body\"});
});
jQuery(document).ready(function (){
jQuery('.minicolors').each(function() {
jQuery(this).minicolors({
control: jQuery(this).attr('data-control') || 'hue',
position: jQuery(this).attr('data-position') || 'right',
theme: 'bootstrap'
});
});
});
jQuery(function(){
new JVMenu('#',{
main: {
delay: 300,
duration: 300,
effect: 'fade',
easing: 'linear'
},
sub: {
delay: 300,
duration: 300,
effect: 'slide',
easing: 'linear'
},
responsive: 992
});
})
jQuery(function(){new JVTop();});
jQuery(function($){ });
</script>
<!--[if lt IE 9]>
<script src=\"https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js\"></script>
<script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>
<![endif]-->
";
// 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/