Syntax Highlighting in Notepad++: how to highlight timestamps in log files -
i using notepad++ check logs. want define custom syntax highlighting timestamps , log levels. highlighting logs levels works fine (defined keywords). however, still struggling highlighting timestamps of form
06 mar 2014 08:40:30,193
any idea how that?
if want simple highlighting, can use notepad++'s regex search mode. open find dialog, switch mark tab, , make sure regular expression set search mode. assuming timestamp @ start of line, regex should work you:
^\d{2}\s[a-za-z]+\s\d{4}\s\d{2}:\d{2}:\d{2},[\d]+
breaking down bit bit:
^
means following regex should anchored start of line. if timestamp appears anywhere start of line, delete this.
\d
means match digit (0-9). {n}
qualifier means match preceding bit of regex n times, \d{2}
means match 2 digits.
\s
means match whitespace character.
[a-za-z]
means match character in set a-z or set a-z, , +
qualifier means match preceding bit of regex 1 or more times. we're looking alphabetic character sequence containing 1 or more alphabetic characters.
\s
means match whitespace character.
\d{4}
\d{2}
earlier, we're matching 4 digits.
\s
means match whitespace character.
\d{2}
means match 2 digits.
:
matches colon.
\d{2}
matches 2 digits.
:
matches colon.
\d{2}
matches 2 digits.
,
matches comma.
[\d]+
works alphabetic search sequence set earlier, one's digits. finds 1 or more digits.
when run regex on document, mark feature highlight matches it. unlike temporary highlighting "find in document" search type can give you, mark highlighting lasts after click somewhere else in document.
Comments
Post a Comment