package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(t(?:h[uứ])? ?(?:tư|[2-7]|hai|ba|năm|sáu|bảy)|chủ nhật)( *)(?: ?(?:đầu|cuối)? ?(?:tuần (?:trước|sau|này)))?$`)
var str = `thứ 2
thứ 3
thứ 4
thứ 5
thứ 6
thứ 7
t2
t3
t4
t5
t6
t7
thứ hai
thứ ba
thứ tư
thứ2
thứ3
chủnhật
Chủ nhật
thứ hai cuối tuần sau
thứ ba cuối tuần sau
thứ tư cuối tuần sau
thứ năm cuối tuần sau
thứ năm đầu tuần sau
thứ sáu đầu tuần sau
thứ bảy tuần sau
chủ nhật tuần trước
chủ nhật tuần này
t8 cuối tuần này
thuhai
thuba
thutu
thunam
tha thu
`
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/