package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)# The pattern should match twice or more.
(?:
# Begin of line.
^
# But not one of these lines:
(?!(?:4-Diepi|5-Mts|.*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*)$)
# Digits and then any chars not beeing line ending, followed by a new line or end of line.
\d+[^\r\n]*(\R|$)
){2,}`)
var str = `Peie
71,176,953
T-re
71,173,557
5-Mts
41,653,495
45678
Sia
36,136,829
36,100,829
78,684,45
4-Diepi
120,829
uteCra
36,100
Oct2018
71,45,78
22 Apr2024
It should not match above.
66456,56,6
9-inches
789,879,89
2-Mts`
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/