package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<!検索結果:)(?<!次の)(?<![0-90-9])(?<![0-90-9][,,、])(?:[〇一二三四五六七八九十百千万億兆0-90-9]|京+)[,,、]?.+[〇一二三四五六七八九十百千万億兆京0-90-9].+件`)
var str = `Issue: with the original regex pattern, everything mathes (numbers + 件), but those that shouldn't partially match as you see below.
******************************************
*THESE BELOW SHOULD MATCH (just the numbers + 件)*
販売実績100万件
販売実績100万件
販売実績1,000件
販売実績1,000件
販売実績1,000,000件です
100,000件
5000件
******************************************
*BELOW PATTERNS SHOULD NOT MATCH*
(☓)検索結果:10件
(x)検索結果:500件
(x)次の100件
(☓)10件表示
(☓)10件を表示
(☓)10件の表示
(x)全件
(x)検索結果:13953952件 <--- problem
(x)検索結果:100,000,000件 <--- problem
(x)検索結果:5000件
(x)次の5,000件
(x)次の5,0000件 <--- problem
(x)次の1000件
(x)次の5万件`
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/