In the standard apache error log file format, we have:
[Mon Jun 17 23:09:46 2002] [error]usage: tie @array, Tie::File, filena
+me, [option => value]... at d:/httpd/apache/perl/velog.pl line 16
[Mon Jun 17 23:24:44 2002] [error] [client 127.0.0.1]File does not exi
I would like to add a <BR> tag after the blocks of [ ] but before the error begins, like this:
[Mon Jun 17 23:09:46 2002] [error]
usage: tie @array, Tie::File, filename, [option => value]... at d:/htt
+pd/apache/perl/velog.pl line 16
[Mon Jun 17 23:24:44 2002] [error] [client 127.0.0.1]
File does not exist: d:/httpd/apache/htdocs/kjh
My first try was to just go with s/^(\[.*\])/$1<br>/;
which worked all too well. . The problem was that it was matching everything up to and including any ]'s in the error string as well. After reading Ovid's writeup(Thank you for Death to Dot Star!
), I changed my regex to s/^(\[^]])/$1<br>/;
. That change fixed things too much in the other way (only capturing the first [ ]). Now, I've come up with what seems to me to be very complicated.
s/^ #start of string
( #start capture
(?: #begin non-capturing repeating
\[ #literal [
[^]]* #anything that isn't a ]
]\s* #ending ] and optional spaces
)+ #end non capturing repeating
) #end capture
/ #end match
Iwas surprised at myself for coming up with this. I would very much appreciate any suggestions you might have to simplify this beast. Have I missed anything (I'm very good at missing the good points)?