package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^[Pp]ython v?(?:(?:(?<epoch>[0-9]+)!)?(?<release>[0-9]+(?:\.[0-9]+)*)(?<pre>[-_\.]?(?<preLabel>(a|b|c|rc|alpha|beta|pre|preview))[-_\.]?(?<preNumber>[0-9]+)?)?(?<post>(?:-(?<postNumber0>[0-9]+))|(?:[-_\.]?(?<postLabel>post|rev|r)[-_\.]?(?<postNumber1>[0-9]+)?))?(?<dev>[-_\.]?(?<devLabel>dev)[-_\.]?(?<devNumber>[0-9]+)?)?)(?:\+(?<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?$`)
var str = `Python 2.7.15
python v3.6.6`
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/