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:
(?
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
VulpesPosted Dec 1, 2011, 6:34 AM
The following worked fine on the file as you've posted it though I wasn't sure whether the absence of an 'Item_Process_Start' line in the final item was an error or not:
PsymonPosted Dec 1, 2011, 6:47 AM
I will check / test this today and see how this performs.
Rather good timing i was just coming on the site to post an update as it seems the following also cured my issue (in part 99%)
var rxBlock = new Regex(rxStripBlock,RegexOptions.RightToLeft | RegexOptions.Singleline);
I never considered righttoleft option in regex :)
However you are right for a large file this is a little slow so i will incorporate your method and benchmark them to see which performs.
That said i can see your method has much more control over how the parameters of the log file are handled and would allow better parsing
Thanks Vulpes your a star