package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(\/?[A-Z][a-z]+(?:\s(?:[A-Z]['a-z]+)+))(?:\s+(lbw|not\sout|(c\.|st|run\sout)\s\(?(\w+)\)?))?(?:\s+((?:b\.\s)(\w+)))?\s+`)
var str = `David Warner lbw b. Hassan 19 16 4 0 118.8%
Joe Burns b. Morkel 73 149 16 0 49.0%
Asad Shafiq c. Rahane b. Morkel 22 38 5 0 57.9%
Yasir Shah not out 1 12 0 0 8.3%
Yasir Shah st Rahane 1 12 0 0 8.3%
Morne Morkel run out (Shah) 11 17 1 1 64.7%`
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/