// 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#"(?ix)#opening tag
\{(RAW|ACCESS|DWNLINK|MODL|\w+)
#optional attributes
(?>
\{ ([^}]*) }
)?
}
#optional text and closing tag
(?:
( #text:= any char except "{", or a "{" not followed by /commandname
[^{]*+
(?>\{(?!/?\1[{}])[^{]*)*?
)
#closing tag
\{/\1}
)?"#).unwrap();
let string = "<div class=\"blog-list-item blog\"><header class=\"entry-title\">
<h1>Welcome to our website</h1>
</header><article id=\"entry-72\" class=\"entry post-72 page et-bg-layout-dark et-white-bg\"><div class=\"jumbotron row\">
<div class=\"col-md-8\">
<ul>
<li>You have a pending job on your neck?…</li>
<li>Do your company need a website makeover ?…</li>
<li>Or a competitive web application ? ?…</li>
<li>Do you need a customized plugin, or a tweak ?…</li>
<li>Maybe you want a personal website ?…</li>
<li>Or a graphic for your new project ?…</li>
</ul>
<div class=\"bg-primary well\">
<h4 class=\"text-center text-white shadow\">Track your project as we work it to perfection...</h4>
</div>
</div>
<div class=\"pull-right col-md-4\">
<h4 class=\"bg-primary text-white well\">Other services we offer</h4>
{ACCESS{type=500}}
<ul>
<li>SEO work for an existing website or new</li>
<li>Bulk SMS</li>
<li>E-currency exchange</li>
<li>Facebook AD</li>
<li>Google AD</li>
</ul>
{/ACCESS}</div>
{RAW{say=email,access=500}} {RAW} <a class=\"btn button large tall green\" href=\"client-area\">Place new Job now as we deliver at the quickest <em>reasonable time</em></a>{/RAW}</div></article></div>";
// 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/