REGEX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Everyone.

I've found this REGEX pattern at
https://coderwall.com/p/snn1ag/regex-to-parse-your-default-nginx-access-logs

(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])

I am missing why it isn't parsing my access log file:

108.170.163.140 - - [11/Sep/2015:09:59:54 -0400] "GET /prayers-for-today/20 HTTP/1.0" 200 14982 "-" "Mozilla/5.0 (Linux; Android 5.0.1; GT-I9505 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.133 Mobile Safari/537.36" "-"

Would someone with a fresh set of eyes have a look for me please?

This is the syntax where I use it:

if (preg_match($pattern, $line, $matches)) {

Thank you.

Ron



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux