package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?:(\d+) Days?)?(?: ?(\d+) Hours?)?(?: ?(\d+) Minutes?)?`)
var str = `142 Days 16 Hours
128 Days 9 Hours 43 Minutes
10 Minutes
48 Hours
1 Day 1 Hour 0 Minutes
`
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/