package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`site[\s\S]{0,100}\/a>`)
var str = `<body>
<!-- Websites navigation menu -->
<ul class="navbar">
<li><a href="index.html">Home page</a>
<li><a href="musings.html">Musings</a>
In the following code, what is the regex (within Sublime's search) for finding "site" (seen within "Websites") and /a> (seen within ) only when there are between 0 and 50 characters of any type in between those two strings? I'd like to be able to perform searches like this on a regular basis, just changing out the two keywords and a distance, thanks.`
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/