Try the following:
func main(){
r := regexp.MustCompile(`(.)`)
for i := 0; i < 255; i++{
d := []byte{byte(i)}
all := r.FindAll(d, -1)
fmt.Println(all)
}
}
The wildcard cannot match byte 10 (ie the new line character). Looks like a bug. I suppose regex was never really meant to work with []byte, but golang offers the []byte functions, so this is kind of an oversight.
You need to tell it to match against new lines .. by specifying the s
flag:
r := regexp.MustCompile(`(?s)(.)`)
Try it in the playground: http://play.golang.org/p/MK-UECa9AV
The s
flag tells the parser to let .
match a new line.