// 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"\:(\s)?(.+)[^\{](\v)").unwrap();
let string = "#main h1 {
color: #333;
}
a {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: underline;
}
body {
margin: 0;
display: table-row;
/*vertical-align: middle;
filter: url(#blur);
background: url('bg.jpg') center top no-repeat #333;
background-clip: cover;
-moz-filter: blur(20px);*/
position: relative;
}
body::before {
content:'';
background: url('bg.jpg') center top no-repeat #333;
background-clip:cover;
background-attachment: fixed;
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
height: 100%;
width: 100%;
filter: url(#blur);
filter: blur(2px);
-webkit-filter: blur(2px);
z-index: -1;
}";
// 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/