Regular Expressions 101

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
\[(?<dttm>.*?)\]\s\[(?:(?<module>.*?):)?(?<level>.*?)\]\s\[pid\s(?<pid>\d*)\]\s\[client\s(?<client>.*?)\]\s(?<message>.*)
/
i

Description

Parse Apache Error Log Line (in default format).

Example: [Wed Jun 01 20:05:21.194671 2016] [core:error] [pid 40699] [client ::1:64519] PHP Parse error: syntax error, unexpected '$t' (T_VARIABLE) in /Projects/trunk/code/php/test.php on line 16

Submitted by garys - 9 years ago