2014-03-06 55 views
0

你好,我有一个日志,例如:腓的preg_match阿帕奇定制日志

x.xx.xxx.xx - username [06/Mar/2014:14:22:24 +0400] "GET /folder/folder1/file.php HTTP/1.1" 200 246 

我使用的preg_match日志文件apache-log-parser.php

标准模式是错误的。

preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $line, $matches); 

请帮忙reg_exp

回答

0

只需卸下最后部分:

preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+)$/", $line, $matches);