[Rspamd-Users] regexp operators, how to use?

Jürgen Echter j.echter at echter-kuechen-elektro.de
Tue Dec 7 21:39:46 UTC 2021


Am Dienstag, Dezember 07, 2021 22:18 CET, schrieb Gerald Galster <list+rspamd at gcore.biz>:
 > So i added something like this to local.d/multimap.conf
>
> TEST_REGEX {
> type = "header";
> header = "from";
> map = "$CONFDIR/local.d/test_regex.map";
> description = "testing regex";
> regexp = true;
> score = 5;
> }
>
> and the map contains:
>
> /Foo\ Bar &! (foo at bar\.com || foo at bar.org)/iu

This is not regular expression syntax.
If you want to learn it see e.g. https://perldoc.perl.org/perlretut

/Foo\ Bar/ -> space between Foo and Bar is not a special char and
does not have to be escaped with backslash.

&! and || seen as logical operators don't work that way in regular expressions.

'.' means any single char. If you want to match the dot as in
foo at bar\.com you also should escape foo at bar\.org.

If you want "something not followed by", try
/Foo Bar (?!(foo at bar\.com|foo at bar\.org))/
where (?! ...) means not followed by.

Your rspamd probably uses hyperscan for regular expressions, which does
not cover all features of pcre. I don't know if lookahead/behind assertions
are well supported. It is better to keep regular expressions simple and fast.

You could also define multiple maps and use composite symbols if you really have to:
https://rspamd.com/doc/configuration/composites.html

Best regards
Gerald

--
Users mailing list
Users at lists.rspamd.com
https://lists.rspamd.com/mailman/listinfo/usersI forgot to escape the second '.', my fault.

Seems i was misleaded by the documentation of hyperscan, as it looks like i could do A&!B.
 
 * The priority of operators are ! > & > |. For example:  
 * 
A&B|C is treated as (A&B)|C, * 
A|B&C is treated as A|(B&C), * 
A&!B is treated as A&(!B). * Extra parentheses are allowed. For example:  
 * 
(A)&!(B) is the same as A&!B, * 
(A&B)|C is the same as A&B|C.I will have a look at your link, need to learn some things, i guess :)

Have a nice day and thanks.


More information about the Users mailing list