package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`Hometown: ([^<]+)(?=\s*<)`)
var str = `<strong><a href="/search/company/company/94613582">Anchor sample Ltd</a></strong><br>
BIS: 94613582 <br>
Hometown: MONTREAL <br>
<div class="hori"></div>
<strong><a href="/search/company/company/046251945">Anchor sample Ltd</a></strong><br>
BIS: 046251945 <br>
Hometown: ALABAMA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/041634545">Anchor sample Ltd</a></strong><br>
BIS: 041634545 <br>
Hometown: GEORGIA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/487915646">Anchor sample Ltd</a></strong><br>
BIS: 487915646 <br>
Hometown: FLORIDA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/165875487">Anchor sample Ltd</a></strong><br>
BIS: 165875487 <br>
Hometown: KANSAS <br>`
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/