package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<ipv6_full>(?:^(?:f[c-f][0-9a-f]{2}|200[1-2]|0?100):).+|(?:.+:0{0,3}1$|(?:.+:ffff:(?:0:)?|^0{0,2}64:ff9b::)(?<ipv4_map>(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})){3})$))`)
var str = `::1
100::
2001::
2001:20::
2001:db8::
2002::
fc00::
fe80::
ff00::
64:ff9b::0.0.0.0
100::
::ffff:0.0.0.0
::ffff:0:255.255.255.255`
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/