package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?:(?<mcversion>\d+\.\d+(?:\.\d+){0,1})-){0,1}(?<fullver>(?<version>\d+(?:\.\d+)*)(?:[-+](?<extra>.*))?)`)
var str = `Raw Version:
1.0.0
1.2.3.4
1.0
Prefixed with version:
1.7.10-1.2.3
1.8.1-10.0.0.1
1.10.10-2
1.5-4.63.2
Extra Information
1.6-4.4.4.4-SNAPSHOT-BULLSHIT
1.6-SNAPSHOT-BULLSHIT
With Metadata Support
1.0.0-alpha+001
1.0.0+20130313144700
1.0.0-beta+exp.sha.5114f85`
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/