re = /^(?P<timestamp>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}-[0-9]{2}:[0-9]{2})\s+(?P<domain>[a-zA-Z0-9]+)\s+\[(?P<msgid>0[xX][0-9a-fA-F]+)\]\[(?P<msgtype>[a-zA-Z]+)\]\[(?P<msgcat>[a-zA-Z]+)\]\s+(?P<objtype>\w+)\((?P<objname>[a-zA-Z_-]+)\):\s+trans\((?P<txnum>[0-9]+)\)(.*?):\s(?P<msgtxt>.*)/
str = '2016-03-16T10:30:18-05:00 DEVESB2 [0x80e0018d][ldap][error] xmlmgr(map-manager): trans(1750947) gtid(1750947): Error querying server 10.158.131.139: Error while searching; see log for details
2016-03-16T10:30:17-05:00 DEVESB2 [0x804000a1][slm][info] throttle(Throttler): trans(1279): Memory(10529899/13448300kB 78.299108 free) Pool(7052687) Ports(127732/127850) Temporary-FS(116/128MB 90.625000 free) File(OK)
2016-03-16T10:30:01-05:00 DEVESB2 [DEVESB][0x80e00176][ws-proxy][error] source-http(DEFAULT_DATA1_HTTP): trans(1750611)[172.27.137.222]: No WS-Proxy service endpoints matched request.
'
# Print the match result
str.match(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