// 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"(?m)<(.*)(?:\s[^>]*?)?>(?:{{)([^<]*?)<\/\1>([^<]*?<[\s\S]*?>[^>]*?)<(.*)(?:\s[^>]*?)?>([^<]*)(?:}})<\/\4>").unwrap();
let string = "<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:15pt\"><span style=\"font-family:宋体\">乙方经办人</span><span style=\"font-family:宋体; color:#e36c0a\"> </span><span style=\"font-family:宋体; font-weight:bold; text-decoration:underline; color:#e36c0a; -aw-import:spaces\">  </span><span style=\"font-family:Calibri; font-weight:bold; text-decoration:underline; color:#e36c0a\">{{</span><span style=\"font-family:宋体; font-weight:bold; text-decoration:underline; color:#e36c0a\">甲方手机号</span><span style=\"font-family:Calibri; font-weight:bold; text-decoration:underline; color:#e36c0a\">}} </span></p>
<div align=\"center\">
<hr size=\"2\" align=\"center\" noshade=\"\" style=\"width:100%; color:#444444; background-color:#444444\" />
</div>
<p style=\"margin-top:0pt; margin-bottom:0pt; line-height:22.5pt; background-color:#ffffff\"><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">我问:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">魔镜啊魔镜,哪块才是这个世界上最易碎的玻璃?</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span><br /><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">魔镜说:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">晕!你最美!你最美行了吧。。。</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span></p>
<div align=\"center\">
<hr size=\"2\" align=\"center\" noshade=\"\" style=\"width:100%; color:#444444; background-color:#444444\" />
</div>
<p style=\"margin-top:0pt; margin-bottom:0pt; line-height:22.5pt; background-color:#ffffff\"><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">买了块几十万的表,结果每天都跑得太快,还不如几十块钱的电子表。</span><br /><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">我问厂家怎么回事,厂家说:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">法拉利是不是比夏利跑得快?对吧?那这个名表当然要比普通表快了!</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span></p>
<div align=\"center\">
<hr size=\"2\" align=\"center\" noshade=\"\" style=\"width:100%; color:#444444; background-color:#444444\" />
</div>
<p style=\"margin-top:0pt; margin-bottom:0pt; line-height:22.5pt; background-color:#ffffff\"><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">儿子说:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">妈妈,包子一定是馒头的妈妈吧。</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span><br /><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">妈妈:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">为什么?</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span><br /><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">儿子:</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">“</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">你看,它长皱纹了。</span><span style=\"font-family:Verdana; font-size:10.5pt; color:#444444\">”</span></p>
<div align=\"center\">
<hr size=\"2\" align=\"center\" noshade=\"\" style=\"width:100%; color:#444444; background-color:#444444\" />
</div>
<p style=\"margin-top:7.5pt; margin-bottom:12pt; line-height:22.5pt; background-color:#ffffff\"><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">爱吃的女孩运气都不会太差,因为食来运转嘛。</span></p>
<div align=\"center\">
<hr size=\"2\" align=\"center\" noshade=\"\" style=\"width:100%; color:#444444; background-color:#444444\" />
</div>
<p style=\"margin-top:7.5pt; margin-bottom:12pt; line-height:22.5pt; background-color:#ffffff\"><span style=\"font-family:Helvetica; font-size:10.5pt; font-weight:bold; color:#383838; background-color:#f5f6f9\">6</span><span style=\"font-family:宋体; font-size:10.5pt; font-weight:bold; color:#383838; background-color:#f5f6f9\">页</span><span style=\"font-family:宋体; font-size:10.5pt; color:#444444\">今天客户说我们公司的设备卡,死活找不到原因,工程师赶到现场,给客户换了个鼠标垫,故障排除。。。</span></p>";
// 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/