package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^0x[0-9a-f]+$`)
var str = `3
999
-3
0
0.0
1.0
0.1
.01
-0.0000000000000000000000000000000001
2e3
-2e3
2e-3
-2e-3
1.0e0
0.1e1
.01e-1
-9.1e3
-9.1e-3
9E5
0e-11
0xff
0XFF
0x0
0xfe3
0e0
.0e-0
.0e5
.0e-5
0.0e0
0.0e123
0.0e-123
-0
-0.0
-0.0000000000000000000000000000000000
-.0
-.0000000000000000000000000000000000
1xff
0x
0x0fg3
0xf4.
.0xf
0xfe-3
-0xff
0.0xff
0xff.1
1e-
e89
.e3
001
-00.2
6.
f
-1
--1
-.1
2-
.-1`
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/