package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)([M,F]\/\d{2}\/((\d{1}((\')|(\’))?(([0,2-9]|1[0-1]?)((\")|(\'\')|(\”))?)?)|\d{1,3}cm|[1-2]m(\d{1,2}(cm)?)?)\s?\[\d{2,3}\s?(lbs|kg)\s?to\s?\d{2,3}\s?(lbs|kg)\]\s?\(((\d{1,2}\s?years?)|(([2-9]|1[0-1]?)\s?months?)|(\d{1,2}\s?years?(\;|\,)?\s?([0,2-9]|1[0-1]?)\s?months?)|(([2-9]|1[0-1]?)\s?weeks?))\)\s?(\s?\+\s?\(([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?[DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)\))?.*)|(^\[Meta\].*)`)
var str = `
M/20/5'10" [150lbs to 180lbs] (2 years; 6 months) + (B: 300lbs; S: 410lbs; D: 480lbs)
F/26/5'2" [52kg to 59kg] (5 years)
M/35/6'3" [203lbs to 175lbs] (7 months) - Additional comments here
M/20/5'10" [150lbs to 180lbs] (2 years; 6 months) + (B: 300lbs; S: 410lbs; D: 480lbs) `
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/