package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)_(1[6-9]|2[0-4])$`)
var str = `x2016_17_7
x2017_188
x2018_199
x2019_20_10
x2020_21_11
x2021_22_12
x2022_23_13
x2023_20_10
x202025_15
x2016_17_16
x2017_18_17
x2018_19_18
x2019_20_19
x2020_21_20
x2021_22_21
x2022_23_22
x2023_20_23
x2020_25_20`
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/