Last active
November 18, 2015 19:40
-
-
Save ei-grad/577567d8903a6815b176 to your computer and use it in GitHub Desktop.
Regular expression to parse apache combined log in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| apache_combined = re.compile( | |
| '(?P<clientip>[\d\.]+) (?P<ident>\S+) (?P<auth>\S+) ' | |
| '\[(?P<timestamp>.*?)\] ' | |
| '"(?P<verb>\S+) (.*) HTTP/(?P<httpversion>\d\.\d)" ' | |
| '(?P<response>\d+|-) (?P<bytes>\d+|-)' | |
| '( "(?P<referrer>.*?)")?' | |
| '( "(?P<agent>.*)")?' | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment