re = /<td data-table-header="The bank [^"]+">([\d|,|.\+]+)<\/td>/m
str = '<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>'
# Print the match result
str.scan(re) do |match|
puts match.to_s
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html