package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)dst\=((?:10\.)|(?:172\.1[6-9]\.)|(?:172\.2[0-9]\.)|(?:172\.3[0-1]\.)|(?:192\.168\.)).+`)
var str = `dst=192.168.1.2
dst=10.10.10.10
dst=101.20.10.7
dst=11.10.10.10
dst=100.26.23.45
dst=123.123.123.123
dst=172.16.24.36
dst=98.23.45.12
dst=10.20.30.40
`
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/