fork download
  1. import re
  2.  
  3. pattern = r"(?P<host>.*?) - (?P<username>\w+) \[(?P<date>[^][]*)] \"(?P<req>[^\"]+)\""
  4.  
  5. s = "219.133.7.154 - price5585 [21/Jun/2019:15:45:53 -0700] \"GET /incubate/incubate HTTP/1.1\" 201 12126"
  6.  
  7. m = re.match(pattern, s)
  8. if m:
  9. print(m.groupdict())
Success #stdin #stdout 0.02s 9572KB
stdin
Standard input is empty
stdout
{'host': '219.133.7.154', 'username': 'price5585', 'date': '21/Jun/2019:15:45:53 -0700', 'req': 'GET /incubate/incubate HTTP/1.1'}