package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?:Name|Email|Operator|Start Time|End Time|Product\/Service|Phone|(?:Company?)).*$`)
var str = `Name: Tan
Email: pk.tan@my.rlb.com
Operator: Jeeva
Start Time: 07/01/2014 14:43:47
End Time: 07/01/2014 15:35:22
Product/Service: 5 Gallon Water Delivery
Phone: 62079991
Company: RL Bersepadu Sdn Bhd
Some other field won't work:scskcnskcnskcnk
Name: Tan
Email: pk.tan@my.rlb.com
Operator: Jeeva
Start Time: 07/01/2014 14:43:47
End Time: 07/01/2014 15:35:22
Product/Service: 5 Gallon Water Delivery
Phone: 62079991
See Company missing here: Above things are matching
`
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/