Regular Expressions 101

Community Patterns

1...56789...902

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

%
^\D{8}(?<time>\d[^\s]*\s[^\s]*)\s(?<severity>\w)\s[/|]\s(?<source>[^\s]*[\:])[\s]*(?<message>.*[/\/n])([\W]*[\w]*){3}[\W]{3}(?<logdate>[\d]*\-[\d]*\-[\d]*)\w(?<logtime>[\d]*\:[\d]*\:[\d]*\.[\d]*)\w\W*$
%
gm

Description

Pars such a log: {"log":"2017-12-19 13:32:01.280700 I | etcdmain: etcd Version: 3.0.17\n","stream":"stderr","time":"2017-12-19T13:32:01.281026986Z"}

Submitted by Alireza - 7 years ago