Regex error in python (weird?)

Aahz Maruch aahz at netcom.com
Tue Aug 29 19:26:54 EDT 2000


In article <39AC2BAD.EAE1246B at uow.edu.au>,
Aleksandar Alimpijevic  <aa44 at uow.edu.au> wrote:
>
>Hi, I have a weird problem when using my regular expression to parse a
>lino from a WebServer log file. The program looks like it got stuck into
>some weird loop somewhere. The problem seems to appear in only one case.

Tim Peters likes to say that anyone who tries to solve a problem with a
regular expression now has two problems.

>This is the format of the line in the file. The regular expression tends
>to check if the line has exactly the same format. It works fine for
>everything except
>        201.120.68.38 - - [05/Jun/2000:16:30:29 +1000] "HEAD /index.html
>HTTP/1.0" 304 -
>If I change line to  (change only in HTTP/1.0 part)
>        201.120.68.38 - - [05/Jun/2000:16:30:29 +1000] "HEAD /index.html
>HaTTP/1.0" 304 -

I'd suggest that you break this operation into several parts.  Start by
splitting the line into three sections: everything before " - - ";
everything between the brackets; and everything after the brackets.  Or
something like that.
--
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Goodbye dinner for Netcom shell, Thurs 9/7, 7:30pm, Mountain View, CA
e-mail me for details



More information about the Python-list mailing list