Reputation: 1
I am trying to form the correct regex to capture strings out of a multi line log like -
AMQ9206: Error sending data to host hic4 (10.254.101.168)(1414).
or
AMQ9999: Channel 'TO.MQH4' to host 'HIC4(1414)' ended abnormally.
multi line log excrepts as follows -
06/17/16 22:45:14 - Process(509640.1) User(mqsystem) Program(runmqchl) Host(mqah103p) Installation(MQAppliance) VRMF(8.0.0.4) QMgr(PRDCDE3A) AMQ9206: Error sending data to host hic4 (10.254.101.168)(1414). --------------------------- amqccita.c : 3166 ---------------------------------- 06/17/16 22:45:14 - Process(509640.1) User(mqsystem) Program(runmqchl) Host(mqah103p) Installation(MQAppliance) VRMF(8.0.0.4) QMgr(PRDCDE3A) AMQ9999: Channel 'TO.MQH4' to host 'HIC4(1414)' ended abnormally.
Upvotes: 0
Views: 103
Reputation: 33496
Depending on the programming language, this will be expressed slightly differently, but the main trick is to enable multi-line mode in your regex. This will allow special characters like ^
and $
to match the beginning and end of a line instead of the beginning and end of the string.
Assuming your log always has this general format of AMQ
followed by 4 numbers, the regex would be something like:
/^AMQ\d{4}: .*$/gm
Upvotes: 1