package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(\bhref="(.*?)\b")(?!.*\1)?`)
var str = ` <div>
<a href="showthread.php?t=5239160" id="thread_title_5239160">программа для точного определения местоположения любого гаджета</a>
<span class="smallfont" style="white-space:nowrap">(<img class="inlineimg" src="https://static.kharkovforum.com/images/misc/multipage.gif" alt="перейти на страницу" border="0" /> <a href="showthread.php?t=5239160">1</a> <a href="showthread.php?t=5239160&page=2">2</a>)</span>
</div>
<div class="smallfont">
<span style="cursor:pointer" onclick="window.open('member.php?u=502041', '_self')">I-am</span>
</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/