package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^\d+(?:(?:,\d{3})*(?:\.\d{1,2})?|\.\d+)$`)
var str = `1.71
171
1.71717171
171.00
1770
1,700
1,700.00
1,777,777
1,777,777.00
1777777.00
1,444444,4444444,444444.22
1,333,333,333.233
171,00
1777777,00
1,00`
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/