In diesem Beispiel wird eine IPv4 Adresse aus einem String extrahiert.
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`.*(((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4})$`)
match := re.FindStringSubmatch("Hans Dampf hat die IP 1.1.1.1")
if len(match) >= 1 {
fmt.Println(match[1])
} else {
fmt.Println("No match")
}
}
