Re: REGEX

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

 



On Fri, Sep 11, 2015 at 12:38 PM, georg chambert <georg.chambert@xxxxxxxxx>
wrote:

> Im not so into regex, but what does the first square brac do ?
> /georg
>
> ----- Original Message ----- From: "Ron Piggott" <
> ron.piggott@xxxxxxxxxxxxxxxxxx>
> To: "PHP General" <php-general@xxxxxxxxxxxxx>
> Sent: Friday, September 11, 2015 4:40 PM
> Subject:  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
>>
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I never figured out why people don't use the existing separator from Apache
to process logs, makes it much more easier. You can try to look @ similar
regex codes and see what you are doing differently:

http://dom.hastin.gs/blog/coding/php-log-process-apache-log-files-with-php/49
http://snipplr.com/view/40524/phplog--process-log-files-with-php/

[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