package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^\[(.*?)\s\d{6}\s\d{3}]\[\d]\[ERROR]`)
var str = `[02112017 072755 332][1][ERROR]> ----Message : IDC_NO_MEDIA
[02112017 072755 332][1][INFO]> ----
[02112017 104502 724][1][ERROR]> ----Message : DEV_NOT_READY
[02112017 104502 724][1][INFO]> ----
[02112017 104503 331][1][ERROR]> ----Message : DEV_NOT_READY
[02112017 104503 331][1][INFO]> ---- `
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/