I\'m trying to parse an Apache Log with regex using Python and assign it to separate variables.
ACCESS_LOG_PATTERN = \'^(\\S+) (\\S+) (\\S+) \\[([\\w:/]+\\s[
You need to make your group 7 optional by adding a ?. Use the following regex:
group 7
?
^(\S+) (\S+) (\S+) \[([\w:/]+\s[+\-]\d{4})\] "(\S+) (\S+)\s*(\S+)?\s*" (\d{3}) (\S+) ↑
See the DEMO