package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\(20(\d{2}|x{2})((\.|-)([0-9]{2}|x{2}|KW(\d{2}|x{2})|Q(x|[1-4])|(([0-9]{2}|x{2})(\.|-)([0-9]{2}|x{2}))))?\)`)
var str = `20000002000
200 0
(2022.xx2000.xx)
(2022.xx) 2000.xx
(2020-20)
(20xx-12)
(20xx.xx-11)
(2002-KW00.00)
(2002-KW00)
(2022.KWxx)
(2021.KW09)
(2021.KW09)
(2021.02)
2022.Qx
2032.Q4
(2020.xx)
2022-Q1
2022 Test
Test 20xx
20202020
.Qx
KW23
KWxx
(20xx)
(.-Q4)
2000-
2000.
`
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/