Regular Expressions 101

Community Patterns

parse nginx log

1

Regular Expression
PCRE (PHP <7.3)

/
(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) (?P<domain>[^ ]+) \- \[(?P<datetime>\d{2}\/[a-zA-Z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (?:\+|\-)\d{4})\] "(?P<method>\w+) (?P<url>[^ ]+) (?P<proto>[^ ]+)" (?P<status>\d+) (?P<bytes>\d+)
/

Description

parse nginx log lines into fields

Submitted by ViKing - 8 years ago