package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^((((r?d_(MON|TUE|WED|THU|FRI|SAT|SUN))_?([0][1-5])?(([-+])([0-9]{3}))?)|(r?d_[0-9]{3}))|rd|((r?m_((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|([0][1-9]|[1][0-2])))_?((d[0-9]{2})|(MON|TUE|WED|THU|FRI|SAT|SUN)_?([0][1-5])?)))$`)
var str = `d_MON_02
rd
rd_029
rd_MON
rd_MON_01
rd_MON_01+007
rd_WED_03-007
rm_JAN_d29
rm_01_d29
rm_JAN_MON02
m_JAN_MON01
rm_JAN_MON
one off second Monday
repeat daily
repead daily on the 29th
repead daily on Monday
repeat first Monday
repeat second Monday with offset of 7 days
repeat second Wednesday with negative offset of 7 days
repeat on 29th of January with 3 characters month name format
repeat on 29th of January with 2 digit numbering month format
repeat second Monday of January
one off first Monday of January
repeat all Mondays in January`
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/