Regular Expressions 101

Library entries

Validate Syslog Messages

Vote

2

Regular Expression
pcre

/
<(?'Priority'[0-9]{1,3})>(?'Date'[a-zA-Z]{1,3}\s(?(?=\s)\s|[0-9])[0-9])\s(?'Time'(?:[0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])\s(?'Host'(?(?=\d)(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+)|\w+)\s(?'Message'.+$)
/

Description

Loading markdown...
Submitted by dislick - 9 years ago