// 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#"(?im)(?:<TD CLASS="label")(?:.*>)(?s)(?<lbl>.*?)(?:<\/TD>).*?(?:<TD NOWRAP>).*?(?:type=)"(?<type>[^"]*)".*?(?:name=)"(?<name>[^"]*)".(?:title=)"(?<title>[^"]*)".*?(?:id=)"(?<id>[^"]*)".*?(?:value=)"(?<value>[^"]*)".*?(?:size=)"(?<size>[^"]*)".*?(?:maxlength=)"(?<maxlength>[^"]*)"*.*?<\/TD>$"#).unwrap();
let string = "<tr>
<TD CLASS=\"label\" NOWRAP VALIGN=\"MIDDLE\">
Average_No_of_Direct_Employees:
</TD>
<TD NOWRAP>
<INPUT CLASS=\"valueEditable\" TYPE=\"text\" NAME=\"_1_1_10_1\" TITLE=\"Average_No_of_Direct_Employees\" ID=\"_1_1_10_1\" VALUE=\"[LL_FormTag_1_1_10_1 /]\" SIZE=\"20\" MAXLENGTH=\"20\" ONCHANGE=\"markDirty();\">
</TD>
</TR>
<!-- End File: datefield.html (End - _1_1_9_1) -->
</TD>
</TR>
<TR CLASS=\"horizontalCellDivider\" >
<TD CLASS=\"labelHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/spacer.gif\" WIDTH=\"1\" BORDER=\"0\"></TD>
<TD CLASS=\"valueHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/tbl-divider-hor.gif\" WIDTH=\"3\" BORDER=\"0\"></TD>
</TR>
<TR>
<TD CLASS=\"label\" NOWRAP VALIGN=\"MIDDLE\">
Average_No_of_Direct_Employees:
</TD>
<TD NOWRAP>
<INPUT CLASS=\"valueEditable\" TYPE=\"text\" NAME=\"_1_1_10_1\" TITLE=\"Average_No_of_Direct_Employees\" ID=\"_1_1_10_1\" VALUE=\"[LL_FormTag_1_1_10_1 /]\" SIZE=\"20\" MAXLENGTH=\"20\" ONCHANGE=\"markDirty();\">
</TD>
</TR>
<TR CLASS=\"horizontalCellDivider\" >
<TD CLASS=\"labelHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/spacer.gif\" WIDTH=\"1\" BORDER=\"0\"></TD>
<TD CLASS=\"valueHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/tbl-divider-hor.gif\" WIDTH=\"3\" BORDER=\"0\"></TD>
</TR>
<TR>
<TD CLASS=\"label\" NOWRAP VALIGN=\"MIDDLE\">
Average_No_of_SubContractors_on-site:
</TD>
<TD NOWRAP>
<INPUT CLASS=\"valueEditable\" TYPE=\"text\" NAME=\"_1_1_11_1\" TITLE=\"Average_No_of_SubContractors_on-site\" ID=\"_1_1_11_1\" VALUE=\"[LL_FormTag_1_1_11_1 /]\" SIZE=\"20\" MAXLENGTH=\"20\" ONCHANGE=\"markDirty();\">
</TD>
</TR>
<TR CLASS=\"horizontalCellDivider\" >
<TD CLASS=\"labelHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/spacer.gif\" WIDTH=\"1\" BORDER=\"0\"></TD>
<TD CLASS=\"valueHorizontalDivider\" COLSPAN=\"1\"><IMG HEIGHT=\"1\" ALT=\"\" SRC=\"/img/tbl-divider-hor.gif\" WIDTH=\"3\" BORDER=\"0\"></TD>
</TR>
<TR>";
let substitution = "<div class=\"medium-6 columns\">\\n <label>${lbl} <!--### INPUT EXAMPLE ### -->\\n <input type=\"${type} <\" NAME=\"${name}\" TITLE=\"${title}\" ID=\"${id}\" VALUE=\"${value}\" SIZE=\"${size}\" MAXLENGTH=\"${maxlength}\" ONCHANGE=\"markDirty();>\\n </label>\\n</div>";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/