Hi, I've been working with some PHP code that uses regexps to parse various
bits out of Apache log file entries, and using BBEdit to test the regexps.
The problem is that the pattern I'm using stopped working sometime between
yesterday and today and as far as I'm aware I haven't changed it!
The pattern is (sorry, long, there's a single space between the .*? and the
HTTP/1..):
^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(.*?)\] "GET /(\d{1,4}).*?
HTTP/1.." 200 .*("[^"]+")?$
and here's an example of the kind of line that it should match (again,
insert spaces in place of line breaks):
139.80.75.149 - - [17/May/2006:14:32:57 +1200] "GET
/1/01/EnvironmentalHarmonyandCommercialSuccess1987.pdf HTTP/1.0" 200 246158
"http://cardrona.eprints.otago.ac.nz/perl/latest" "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.1; SV1)"
Now the pattern *does* match the above just fine; the problem is that it
doesn't capture correct sub-patterns. From the above line, I get the
following:
\1 = 139.80.75.149 (correct)
\2 = 17/May/2006:14:32:57 +1200 (correct)
\3 = 1 (correct)
\4 = (incorrect)
\4 should contain the user-agent string from the end of the line, and did up
until yesterday, but for some reason it's no longer working. If I remove the
? just before the $, \4 is then correct, but then the pattern fails to match
lines that have no trailing user-agent string (of which there are many). I
added the ? yesterday for precisely that reason, *and it worked correctly*
in both BBEdit and PHP. Today it doesn't work in either, and I don't know
why.
I'm completely stumped. Help?
(FWIW: BBEdit 8.6, Mac OS X 10.4.8, PHP 4.4.2)
--
Nigel Stanger, <http://www.business.otago.ac.nz/infosci/>
Dept. of Information Science, <http://xri.net/=nigel.stanger>
University of Otago, Dunedin, NEW ZEALAND. +64-3-479-8179
"Nearly all men can stand adversity, but if you want to test a man's
character, give him power." --- Abraham Lincoln
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>