package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?:Server\sTime:\s?(.*)|Username:\s?(.*)|Important\sData:\s?(\w+))`)
var str = `$input = @"
Server Time: 4/13/2016 12:29 PM
Username: RBullwinkle
Lorem ipsum dolor Important Data: rosebud sit amet
"@;
$input = @"
Lorem ipsum dolor Important Data: differentORder sit amet
Server Time: 2/29/2085 12:29 PM
Username: sweaver2112
"@;`
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/