package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)'(?P<ts>\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ).*?\bdb=(?P<db>\S*).*?\buser=(?P<user>\S*).*?LOG:\s+(?P<query>.*?);?$`)
var str = `'2022-05-08T04:18:43Z UTC [ db=dev user=test pid=1073922359 userid=100 xid=2063 ]' LOG: alter table my_table alter column string type varchar(16);`
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/