package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b\d+(?:,\d+)*`)
var str = `this is number 88 and rest of the text
this is number 2,563 and rest of the text
after I export it into excel. Problem is that I'm using custom tool (not programming language ) that excepts text as an input, regex pattern and export the output. This is why I need single pattern that eliminate space and produce either 88 or 2563 or any other number. The commas are every 3 positions obviously, so it can also be 1,345,321 as well as just single number 5 between "this is number .... and rest of the text"`
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/