On Mon, Mar 8, 2010 at 9:34 AM, spir <[email protected]> wrote:
> On Mon, 8 Mar 2010 16:12:35 +0000
> Stephen Nelson-Smith <[email protected]> wrote:
>
>> Hi,
>>
>> I've written this today:
>>
>> #!/usr/bin/env python
>> import re
>>
>> pattern = 
>> r'(?P<ForwardedFor>^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(,
>> [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1})
>> (?P<RemoteLogname>(\S*)) (?P<RemoteUser>(\S*))
>> (?P<Timestamp>(\[[^\]]+\]))
>> (?P<FirstLineOfRequest>(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)
>> (?P<Status>(\S*)) (?P<Size>(\S*))
>> (?P<Referrer>(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)
>> (?P<UserAgent>(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)(
>> )?(?P<SiteIntelligenceCookie>(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)'
> [...]
>> It works fine, but it looks pretty unreadable and unmaintainable to
>> anyone who hasn't spent all day writing regular expressions.

You might want to consider Plex:
www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to