$re = '/(?ms)EventCode\=5145.*Message\=A network share object was checked to see whether client can be granted desired access./m';
$str = 'LogName=Security
SourceName=Microsoft-Windows-Security-Auditing
EventCode=5145
EventType=4
Type=Success Audit
ComputerName=xxxx
Category=11111
CategoryString=none
RecordNumber=xxxx
Message=A network share object was checked to see whether client can be granted desired access.
Subject:
Security ID:
Account Name:
Account Domain:
Logon ID:
Network Information:
Object Type: File
Source Address:
Source Port:
Share Information:
Share Name:
Share Path: \\
Relative Target Name: x.dxmdg.com\\Policies\\{123456789456456456454654464546464558655}\\Machine\\Preferences\\Registry\\Registry.xml
Access Request Information:
Access Mask:
Accesses:
Access Check Results:';
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