package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\b((?|(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z,.]*(?: (\d{2}(?:th|st|nd|rd)?)?[,.])?|(\d{2}) (?:(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z,.]*)?) (\d{4}))`)
var str = `text Mar 20, 2009 text
text March 20, 2009 text
text 20 Mar. 2009 text
text Sep 2010 text
text Mar 20th, 2009 text
text Mar 21st, 2009 text
`
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/