Psymon

Psymon

  • NA
  • 18
  • 7.1k

Regex Incorrect parameters

Nov 30 2011 12:23 PM
Hi All

Thanks in advance for any assistance. I understand there are a multitude of regex questions and answers out there but i can seem to nail this one....

I am attempting to parse log file data, everything appeared to be working ok until comparing the result sets with the original logs.

I have the following log structure:

07/11 22:49:36:808: Item_Process_Start
07/11 22:49:36:808: LogData
...LogData
...LogData
...LogData
...LogData
07/11 22:49:46:990: Item_Process_End_Success

07/11 22:49:36:808: Item_Process_Start
07/11 22:49:36:808: LogData
...LogData
...LogData
...LogData
...LogData
07/11 22:49:46:990: Item_Process_End_Failed

07/11 22:49:36:808: LogData
...LogData
...LogData
...LogData
...LogData
07/11 22:49:46:990: Item_Process_End_Success

I am trying to capture log data for items between Item_Process_Start and Item_Process_End_Success i do not want to include the failed items data as it is for generating a report of successful items only.

My regex (quite bloated) is as follows:

(?<day>\d{1,2}:)/(?<month>\d{1,2}:)[\s](?<hour>\d{1,2}:)(?<minute>\d{1,2}:)(?<seconds>\d{1,2}:)(?<ms>\d{3}:)\sItem_Process_Start(?s:.*?.*)(?<day>\d{1,2}:)/(?<month>\d{1,2}:)[\s](?<hour>\d{1,2}:)(?<minute>\d{1,2}:)(?<seconds>\d{1,2}:)(?<ms>\d{3}:)\sItem_Process_End_Success

It seems this is a rather greedy search and will also capture failed all items?

Any help on how i can capture the successful items only would be great.

Many thanks

Answers (2)