-
Notifications
You must be signed in to change notification settings - Fork 3
Testing the PCRE regex
The following tools can be used to test the PCRE regexes
(Perl Compatible Regular Expressions) in the format file. Bear in mind that
some characters, including the "\
" (backslash) character, have to be escaped
in the strings in the json
format file, so two backslashes ("\\
") should be
written there instead of one.
-
The https://regex101.com/ website is really useful for testing and writing regular expressions. Copy the work-in-progress regex there, and a line to be matched from
xensource.log
, and modify the regex until it matches. -
Then test with the
pcregrep
tool, which is agrep
tool that uses PCRE regexes, that the regex matches every line in axensource.log
file. By inverting the match, thepcregrep -v <regex to be tested>
command will output all the non-matching lines.For the emitted non-matching lines, go back to step 1. and amend the regex until it matches the line, then repeat the procedure.