package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b65((?:\s(?:\d|[1-57-9]\d|6[0-47-9]|\d{3,}))+?)\s66\b`)
var str = `10 20 30 40 65 45 44 67 100 200 65 40 66 88 65
10 20 30 40 65 45 44 67 100 200 65 40 66 88 66 <== see lazy matching
10 20 30 40 65 45 44 67 100 200 65 66 66 88 65 <== no valid match
10 20 30 40 65 45 44 40 66 200 65 40 66 88 65 <== Two valid ranges
10 20 30 40 65 45 44 68 100 200 77 40 66 88 65 <== No '65' between`
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/