Pages: 1
RSS
regular expressions, spam filter using regular expressions
 
I use K9 to evaluate mail and assign a spam percentage.  K9 adds a line to the header such as
X-Text-Classification: spam[85.7%]
and under 2.x, I had a filter using a regular expression that deleted mail with a spam rating above 70% and moved other suspected spam to a check folder.

With the 3.x filtering system, I haven't been able to compose a filter that handles regular expressions.  I put my spam rules in the common filters.

My first attempt was a rule that looks for the additional header line and checks the percentage:

$$$$ TB! Message Filter $$$$
beginFilter
UID: [414B8310.01C491E0.64467605.2A6B661E]
Name: common\20X-Text-Classification:\20spam[70-100%]
Filter: {\0D\0A\20`5`15`X-Text-Classification:\20spam/5C[[7-9][0-9]/5C.[0-9]%/5C]\0D\0A}
Delete
IsActive
endFilter

this hasn't worked, so I changed it to look for the specific header entry X-Text-Classification: and match the percentage just on that line

$$$$ TB! Message Filter $$$$
beginFilter
UID: [414B8310.01C491E0.64467605.2A6B661E]
Name: common\201.X-Text-Classification:\20spam[70-100%]
Filter: {\0D\0A\20`7`X-Text-Classification`15`spam/5C[[7-9][0-9]/5C.[0-9]%/5C]\0D\0A}
Delete
IsActive
endFilter

That hasn't worked either.  My last resort rule does match, but puts every spam, regardless of the percentage into the junk folder.

$$$$ TB! Message Filter $$$$
beginFilter
UID: [414B8310.01C491E0.59B4B898.7C7E7EFC]
Name: common\20X-Text-Classification:\20spam
Filter: {\0D\0A\20`5`2`X-Text-Classification:\20spam\0D\0A}
MoveMessage folder \5C\5C\5C$JUNK$
IsActive
endFilter

Got any ideas on how I can get the regular expression to match the way I want it?


 
Quote
Dan James wrote:
spam/5C[[7-9][0-9]/5C. [0-9]%/5C]\0D\0A}
Okay, it's easy
you have one space in RE after dot
5C.<space>[0-9]

Also - condition can be simplified to "match" from original "Mathes all as Regexp" (I tested and it works correctly)

RE also can be shortened to smth. like
spam.[7-9]\d\.
--
Errare humanum est
Pages: 1