Re: REGEX
| From: | georg chambert | Date: | Fri, 11 Sep 2015 16:38:45 +0000 |
| Subject: | Re: REGEX | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325109@lists.php.net to get a copy of this message | ||
Im not so into regex, but what does the first square brac do ?
/georg
----- Original Message ----- From: "Ron Piggott" <ron.piggott@actsministries.org>
To: "PHP General" <php-general@lists.php.net>
Sent: Friday, September 11, 2015 4:40 PM
Subject: [PHP] REGEX
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