Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?'DateTime'(?'Month'[A-Za-z]+)\s+(?'Day'0?[1-9]|[12][0-9]|3[01])\s+(?'Time'[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{1,3})?))\W(?'Full_Host'[alnum]|(?:(?'Host_prefix'(?:[A-Za-z])-?)(?'Host'[A-Za-z]+)-*(?'Host_suffix'-{1}[A-Za-z]+)))\W(?'Msg_Sender'(?:\s?\S+:\s)+)?(?'Log_Msg'[[:blank:][:alnum:][:punct:]]+)
/
gm

Description

This was build on gentoo with english_ca.utf8 IIRC. Might not work for other distros... or locales supports -as the delimiter of hostname suffixing/prefixing

Submitted by Wolf1098 - 6 months ago