M
MENTAT
Hi,
I have a log file that looks something like this
2005-03-29 17:17:11.293|DEBUG|Line 1|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.293|DEBUG|Line 9|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.309|INFO|Line 4|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.319|DEBUG|Line 9|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
I am trying to write a regular expression that extracts all the log
entries for a given value of "Line".
So if I wanted to look at the entries for Line 4 I want the output to
look something like
2005-03-29 17:17:11.309|INFO|Line 4|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
Note that I want everything in the line before the "Line 4" text as
well, such as time.
I tried using "<<<<<<<(.*?\|Line 4.*?)>>>>>>>(.*?)<<<<<<<" as the
regular expression (with the ms global modifiers), but the problem is
it matches everything from the beginning of the file (basically the
first <<<<<<<) to the "Line 4". Making .* non-greedy doesn't help
because after it finds the first <<<<<<< the non-greedy match goes all
the way upto the first "Line 4".
Replacing <<<<<<< with the beginning of line (^) doesn't make any
difference either because after the start of the first line, the .*?
still matches everything until "Line 4".
I tried using lookahead and lookbehind assertions as well, but to no
avail. This "<<<<<<<$\(.(?!$)*\|Line 4.*?)>>>>>>>(.*?)<<<<<<<" doesn't
match anything.
Ofcourse, if i remove the s global modifier, i can easily match it
using "(^.*\|Line 4.*)", but then I can't get all the (variable) lines
between <<<<<<< and >>>>>>>. The .* won't match across new line.
Any idea how this problem could be solved? Any help is much
appreciated.
Thanks in advance.
I have a log file that looks something like this
2005-03-29 17:17:11.293|DEBUG|Line 1|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.293|DEBUG|Line 9|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.309|INFO|Line 4|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
2005-03-29 17:17:11.319|DEBUG|Line 9|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
I am trying to write a regular expression that extracts all the log
entries for a given value of "Line".
So if I wanted to look at the entries for Line 4 I want the output to
look something like
2005-03-29 17:17:11.309|INFO|Line 4|Actual Log output line 1
Actual Log output line 2
Actual Log output line 3
Actual Log output line ...
<<<<<<<
Note that I want everything in the line before the "Line 4" text as
well, such as time.
I tried using "<<<<<<<(.*?\|Line 4.*?)>>>>>>>(.*?)<<<<<<<" as the
regular expression (with the ms global modifiers), but the problem is
it matches everything from the beginning of the file (basically the
first <<<<<<<) to the "Line 4". Making .* non-greedy doesn't help
because after it finds the first <<<<<<< the non-greedy match goes all
the way upto the first "Line 4".
Replacing <<<<<<< with the beginning of line (^) doesn't make any
difference either because after the start of the first line, the .*?
still matches everything until "Line 4".
I tried using lookahead and lookbehind assertions as well, but to no
avail. This "<<<<<<<$\(.(?!$)*\|Line 4.*?)>>>>>>>(.*?)<<<<<<<" doesn't
match anything.
Ofcourse, if i remove the s global modifier, i can easily match it
using "(^.*\|Line 4.*)", but then I can't get all the (variable) lines
between <<<<<<< and >>>>>>>. The .* won't match across new line.
Any idea how this problem could be solved? Any help is much
appreciated.
Thanks in advance.