I\'m porting a library from Ruby to Go, and have just discovered that regular expressions in Ruby are not compatible with Go (google RE2). It\'s come to my attention that Ru
how should I re-write these expressions?
Add some Ps, as defined here:
(?P\d{4})-(?P\d{2})-(?P\d{2})
Cross reference capture group names with re.SubexpNames().
And use as follows:
package main
import (
"fmt"
"regexp"
)
func main() {
r := regexp.MustCompile(`(?P\d{4})-(?P\d{2})-(?P\d{2})`)
fmt.Printf("%#v\n", r.FindStringSubmatch(`2015-05-27`))
fmt.Printf("%#v\n", r.SubexpNames())
}