package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`Group:\s+Security\s+ID:\s+[^\\]*\\(.+?)\s+(?:Account|Group)\s+Name:`)
var str = `<13>Jan 09 12:33:50 TESTSRV1 AgentDevice=WindowsLog AgentLogFile=Security PluginVersion=7.2.4.86 Source=Microsoft-Windows-Security-Auditing Computer=corp.devnet.com OriginatingComputer=TESTSRV1 User= Domain= EventID=4755 EventIDCode=4755 EventType=8 EventCategory=13826 RecordNumber=1244048130 TimeGenerated=1483983229 TimeWritten=1483983229 Level=0 Keywords=0 Task=0 Opcode=0 Message=A security-enabled universal group was changed. Subject: Security ID: CORP\TESTUSR1 Account Name: TESTUSR1 Account Domain: CORP Logon ID: 0x220f7a57 Group: Security ID: CORP\VirtualUsers Group Name: VirtualUsers Group Domain: CORP Changed Attributes: SAM Account Name: - SID History: - Additional Information: Privileges: -
<13>Jan 09 12:33:50 TESTSRV1 AgentDevice=WindowsLog AgentLogFile=Security PluginVersion=7.2.4.86 Source=Microsoft-Windows-Security-Auditing Computer=corp.devnet.com OriginatingComputer=TESTSRV1 User= Domain= EventID=4755 EventIDCode=4755 EventType=8 EventCategory=13826 RecordNumber=1244048130 TimeGenerated=1483983229 TimeWritten=1483983229 Level=0 Keywords=0 Task=0 Opcode=0 Message=A security-enabled universal group was changed. Subject: Security ID: CORP\TESTUSR1 Account Name: TESTUSR1 Account Domain: CORP Logon ID: 0x220f7a57 Group: Security ID: CORP\VM Admins Group Name: VM Admins Group Domain: CORP Changed Attributes: SAM Account Name: - SID History: - Additional Information: Privileges: -
Group: Security ID: CORP\Some Strange Account Name:`
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/