I try to parse this string:
[Wed May 06 15:09:08.160122 2015] [proxy_fcgi:error] [pid 30987:tid 140285789038336] [client 192.168.56.1:39157] AH01071: Got error 'PHP message: PHP Fatal error: Undefined class constant 'self::TF_TEASER_LONG' in /var/www/foo/admin/server/php/UploadHandler.php on line 588
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /var/www/foo/admin/server/php/index.php:0
PHP message: PHP 2. UploadHandler->__construct() /var/www/foo/admin/server/php/index.php:14
PHP message: PHP 3. UploadHandler->initialize() /var/www/foo/admin/server/php/UploadHandler.php:172
PHP message: PHP 4. UploadHandler->post() /var/www/foo/admin/server/php/UploadHandler.php:187
PHP message: PHP 5. UploadHandler->handle_file_upload() /var/www/foo/admin/server/php/UploadHandler.php:767
', referer: http://foo.com/admin/module.php?id=29
What I expect as matches at the end would be:
1 -> Wed
2 -> May
3 -> 06
4 -> 15
5 -> 09
6 -> 08
7 -> 2015
8 -> proxy_fcgi:error
9 -> 192.168.56.1:39157
10 -> PHP Fatal error
11 -> Undefined class constant 'self::TF_TEASER_LONG'
12 -> /var/www/foo/admin/server/php/UploadHandler.php
13 -> 588
14 -> PHP message: PHP 1. {main}() /var/www/foo/admin/server/php/index.php:0
PHP message: PHP 2. UploadHandler->__construct() /var/www/foo/admin/server/php/index.php:14
PHP message: PHP 3. UploadHandler->initialize() /var/www/foo/admin/server/php/UploadHandler.php:172
PHP message: PHP 4. UploadHandler->post() /var/www/foo/admin/server/php/UploadHandler.php:187
PHP message: PHP 5. UploadHandler->handle_file_upload() /var/www/foo/admin/server/php/UploadHandler.php:767
15 -> http://foo.com/admin/module.php?id=29
I'm currently at this regex and already fail understanding basic principles:
/(\[(.*?)\])?((?<=\')(.*)(?=\'))?(, referer: (.*))*/g
- Why do I have to put "?" behind the group
(\[(.*?)\])
? - Why does it only match those 4 bracket groups if I don't put the "?" in?
- Why can't I put "{4}" behind the group in 1. to match it 4 times?
Here is a testcase: