Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:(?'Date'\d{4}-\d{1,2}-\d{1,2})\s+(?'Time'\d{2}:\d{2}:\d{2}),?\d{3}\s+(?'LogLevel'INFO|DEBUG|WARN|ERROR|FATAL)\s+(?'PID'\d+)\s+(?'Logger'[a-z.]+)\s+-?\s+)?(?'Message'.+)$
/
gim

Description

parsing log file

Submitted by Oddbjørn Haaland, Sander Struijk - 10 years ago