// 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"<center>(.|\n)*<\/center>").unwrap();
let string = "</head>
<body style=\"background-color:#9b9b9b;\">
**<center>
<table width=\"580\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class =\"responsive-table\" style=\"background-color:#3e5b3e;border:solid thin #3e5b3e;\" >
<tbody>
<tr>
<td background=\"http://app.randomsite.com/js/ckfinder/userfiles//images/banner.jpg\" style=\"padding-top:20px;padding-right:20px;padding-left:20px;\" class=\"hideForMobile\"><h1 style=\"font-family:Arial, Helvetica, sans-serif;font-size:20px;font-weight:bold;text-align:right;color:#eee;vertical-align:bottom;text-decoration:none;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;\" >some message</h1></td>
</tr>
<tr>
</center>**
<!---Start of Banner Image--->
<td><a href=\"{{Custom1}}\" style=\"color:inherit;text-decoration:none;\" ><img src=\"http://app.clientcommand.com/js/ckfinder/userfiles//images/top-dollar-ford-banner.jpg\" alt=\"\" class=\"table.responsiveImage\" style=\"display:block;width:100%;border-style:none;\" /></a></td>
<!---End of Banner Image--->
</tr>
<tr>";
// 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/