|Problems? Is your data what you think it is?|
pattern matching (greedy, non-greedy,...)by cacophony777 (Initiate)
|on Dec 17, 2009 at 00:05 UTC||Need Help??|
cacophony777 has asked for the
wisdom of the Perl Monks concerning the following question:
I've been trying to write a script to generate some useful output based on a log file, and I ran into the issue mentioned in this thread.
Specifically, the problem I'm trying to solve involves matching a group of log lines.
I want to match each PATTERN, but have the match also include the most recent preceeding KEY (and everything in between). So these are the two matches I'm interested in:
If I do something like KEY.*PATTERN the entire contents get the match, and if I do KEY.*?PATTERN it matches everything from the first KEY to the first PATTERN. I've also tried .*KEY.+?PATTERN which just matches the very last group.
If you've got any insight it would be greatly appreciated.