How to add comments in Regex

Updated 2 days ago by admin

This article explains how you can use comments in Rule Regex to comment on entries within the regex. Important

Comments do not function within Custom Rule Data, and will invalidate any rule it is being used with.

Comments can only be done within Rule Regex and has a very distinct format.

A comment is formatted like so: (?#comment here)regex

To create more than a single option, or comment, you separate them with a pipe |, and repeat the process: (?#comment here)regex|(?#comment there)regex2

Regex should be one continuous line and never utilise new lines.

An example of comments within Rule Regex is as follows:

(?#Comment number 1)^$|(?#Comment number 2)Marketing Medium   What this does is look for either an empty entry, or for Marketing Medium in the subject line. When this is used in a rule for detection the detection is completed successfully.


How did we do?