package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)Tableau Server (?<Service>[^']+)'\s*\(?(?<PD>\d+)?\)?\s+(?:is|status\s+is)\s+(?<Status>[\w\s]+)\.`)
var str = `2018-05-25 02:21:30.270 -0500_EXACT_10.218.108.14:RTEEPK08_:pid=12466_0x4364712fuser=request=_ RTEEPK08:
Status: DEGRADED
'Tableau Server Data Engine' (7653) is running.
'Tableau Server Coordination Service 0' (7633) is running.
'Tableau Server Search and Browse 0' (2542) is running.
'Tableau Server Tabadmin Service 0' (25262) is running.
'Tableau Server Gateway' (252564) is running.
'Tableau Server Cluster Controller' is stopped.
'Tableau Server Repository' status is not available.
'Tableau Server File Store' status is not available.`
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/