// 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"\/\/==start==\n(.+\n)*\/\/==end==").unwrap();
let string = "var originalString = `// @Author: someone
// @Date: 2018-01-23T16:46:09-04:00
// @Email: dddddddd@gmail.com
// @Filename: _material.themes.scss
// @Last modified by: Someone
// @Last modified time: 2018-01-23T18:40:39-04:00
@include angular-material-theme($theme);
.app-dark {
@include angular-material-theme($dark-theme);
}
.app-pink {
@include angular-material-theme($pink-theme);
}
//==start==
//==end==`";
// 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/