0

i'm using the following regex regex=re.compile("""(?P<responce_time>\s\d+\.\d+\s)""", re.M) to get all response times in my nginx log file

line = 192.168.1.1 - - [08/Sep/2014:15:15:15 +0100] "GET / HTTP/1.0" 200 612 "-" "-" 4.038 - .

The variable line` is always rotating with new log entries

print(Regex.match(line).groups()) this returns AttributeError: NoneType Object has no attribute group

Any ideas ?

The regular expression is vaild http://regex101.com/r/yP5jV0/2,

miggy282
  • 31
  • 1
  • 6

1 Answers1

2

use regex.search instead of regex.match. The re.match matches only at the beginning of a string whereas re.search will match anywhere in the string.

mgilson
  • 300,191
  • 65
  • 633
  • 696