Created
September 3, 2016 08:32
-
-
Save miticojo/b16bb13e78572c2d2fac82d9516d5c32 to your computer and use it in GitHub Desktop.
Regex for SYSLOG format RFC3164 and RFC5424
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RFC3164 https://www.ietf.org/rfc/rfc3164.txt (obsolete) | |
var regex_rfc3164 = /([A-Z][a-z][a-z]\s{1,2}\d{1,2}\s\d{2}[:]\d{2}[:]\d{2})\s([\w][\w\d\.@-]*)\s(.*)$/; | |
// RFC5424 https://www.ietf.org/rfc/rfc3164.txt | |
var regex_rfc5424 = /(?:(\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}(?:\.\d{1,6})?(?:[+-]\d{2}[:]\d{2}|Z)?)|-)\s(?:([\w][\w\d\.@-]*)|-)\s(.*)$/; | |
// valid string for regex test | |
var msg_rfc3164 = "<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8"; | |
var msg_rfc5424 = "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
God bless you