Spam Filter Pattern Matching

M

mossoft

I use SpamAssassin as a SPAM detector, the rules for the Bayes filter
appear to be Perl based.
I need a rule which detects a string in the subject like "Re: ABCDE,
random three words", where the ABCDE bit can be between 2 and 8 upper
case characters, and I came up with:

/Re: [A-Z]{2,8}, .{1,20}? .{1,20}? .{1,20}?/i

Does this look about right to all you experts?

Ta.

M.
 
D

Dan Wilga

I use SpamAssassin as a SPAM detector, the rules for the Bayes filter
appear to be Perl based.
I need a rule which detects a string in the subject like "Re: ABCDE,
random three words", where the ABCDE bit can be between 2 and 8 upper
case characters, and I came up with:

/Re: [A-Z]{2,8}, .{1,20}? .{1,20}? .{1,20}?/i

The one I wrote yesterday (but haven't tested yet) is:

^Re:\s[A-Z][A-Z]+,(\s[a-z]+){3}

I'd rather not assume the CAPS part will be from 2-8 chars, or that any
of the individual words will be from 1-20 chars.

In my experience, these subjects always have all lowercase alphas in the
three words after the comma, so using "." here is overkill, IMHO.

I've also found when writing regexps that \s is your friend. It's almost
always preferable to use \s (or even \s+), rather than assume the
character will be a real space. It might be a tab or a carriage return.
Granted, it's not too likely in an email subject, but as a general rule
it's very often true, and costs next to nothing.
 
D

Dan Wilga

Dan Wilga said:
The one I wrote yesterday (but haven't tested yet) is:

^Re:\s[A-Z][A-Z]+,(\s[a-z]+){3}

No sooner did I write the above, then I got a piece of spam with an
apostrophe in the three words at the end :-(.

Perhaps this would work better:

^Re:\s[A-Z][A-Z]+,(\s[a-z\']+){3}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top