[Rspamd-Users] Regex in Multimap does not work

Andreas Wass - Glas Gasperlmair a.wass at glas-gasperlmair.at
Tue Nov 30 09:45:19 UTC 2021


Hi all,

next string i'm not able to match. I got a lot emails with Subject 
exactly like following line

Subject: Re:

what i tried and works fine at https://regex101.com/...

/Subject: Re:\z/i MY_OWN_SYMBOL:8
/Subject: Re:\$/i MY_OWN_SYMBOL:8

.. is not working in rspamd

thx for helping me :-)
Andi

Am 19.11.2021 um 14:19 schrieb Gerald Galster:
>>> i have a multimap for my headers to add score 8, if regex matches.
>>> Rule is defined in /etc/rspamd/local.d/multimap.conf
>>>
>>> MY_OWN_SYMBOL {
>>>    type = "content";
>>>    filter = "headers"; # can be headers, full, oneline, text, rawtext
>>>    map = "${LOCAL_CONFDIR}/local.d/gasp_scoring_subject.map";
>>>    description = "Gasperlmair Scoring-Header";
>>>    regexp = true;
>>>
>>> I want to match following string in subject (beginning with the word
>>> auftrag)
>>> auftrag Apotheke
>>>
>>> but the following regex does not match the string auftrag Apotheke
>>>
>>> /^auftrag Apotheke/ MY_OWN_SYMBOL:8
>>>
>>> It only works, if i'm not using ^ but then it also matches words
>>> beginning with  ...auftrag (for Example)
>>>
>>> Thx for helping
>>
>> \b
>
> Just to elaborate, \b means boundary. It's not a char, it's the
> transition from a word-character to a non-word-character or vice
> versa.
>
> /\bauftrag/ does not match e.g. /Beauftragter/ although it contains
> "auftrag" because the boundary is missing.
>
>
> \b     Match a \w\W or \W\w boundary
>
> \w     Match a "word" character (alphanumeric plus "_", plus
>         other connector punctuation chars plus Unicode marks)
>
> \W     Match a non-"word" character
>
> https://perldoc.perl.org/perlre
> https://perldoc.perl.org/perlretut
>
> In case you use hyperscan, keep in mind it has not all the feature
> of pcre (subexpressions, ...).
>
> https://www.hyperscan.io/2015/10/20/match-regular-expressions/
>
> Or you might try
>
> /^Subject: auftrag Apotheke/
>
> Best regards,
> Gerald



More information about the Users mailing list