// 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)<td data-table-header="The bank [^"]+">([\d|,|.\+]+)<\/td>"#).unwrap();
let string = "<div class='index-currency-table'>
<!--http://1000hz.github.io/bootstrap-validator/#validator-usage-->
<div class=\"row\">
<div class=\"col-xs-12\">
<table class=\"table--exchange table--exchange--responsive\">
<thead>
<tr>
<th scope=\"col\">Currency</th>
<th scope=\"col\">Nominal</th>
<th scope=\"col\">The bank buys</th>
<th scope=\"col\">The bank sells</th>
<th scope=\"col\">BNB</th>
</tr>
</thead>
<tbody>
<tr>
<td data-table-header=\"Currency\">
<a href=\"/en/rates-indexes/currency-rates/USD/\" target=\"_self\" title=\"United States Dollar\">
<span class=\"flag-icon flag-icon-us\"></span> USD
</a>
</td>
<td data-table-header=\"Nominal\">1</td>
<td data-table-header=\"The bank buys\">1.581200</td>
<td data-table-header=\"The bank sells\">1.646100</td>
<td data-table-header=\"BNB\">1.614390</td>
</tr>
</tbody>
</table>
</div>
<!--col-->
</div>
<!--row-->
</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/