package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^-?(?!0\d)\d+\.?\d*$`)
var str = `0.500
3
0
0.0
30
0.
500000
4000.22
0.50
.3
.44
00
00.5
03.3
00
02
00.0
03
-03
-01
-01.
0004`
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/