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:'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html