$re = '/Group:\s+Security\s+ID:\s+[^\\\\]*\\\\(.+?)\s+(?:Account|Group)\s+Name:/';
$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:';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php