package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)<td data-table-header="The bank [^"]+">([\d|,|.\+]+)<\/td>`)
var 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>`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/