You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Cory Hawkless <co...@hawkless.id.au> on 2009/06/27 09:26:33 UTC

SA RegEx Rules

Hi all,

 

Been doing some reading on RegEx and even coming from a programming
background it is a bit intimidating, my problem is I haven't been able to
find a good source of information on exactly what\how SpamAssassin matches
the RegEx rules when scanning and what variant of RegEx is being used?(I.E
what syntax is and is not allowed?)

 

I'd like to be able to make my own simple rules but it's proving quite
difficult, Maybe a tool that I can use the build Regular Expressions would
help?

 

I'm sure there are PELNTY of other out ther that are rather bamboozled by
this also and would benefit greatly from any assistance.

 

Thanks in advance

Cory

 

 


Re: SA RegEx Rules

Posted by RW <rw...@googlemail.com>.
On Sat, 27 Jun 2009 16:56:33 +0930
"Cory Hawkless" <co...@hawkless.id.au> wrote:

> Hi all,
> 
>  
> 
> Been doing some reading on RegEx and even coming from a programming
> background it is a bit intimidating, my problem is I haven't been
> able to find a good source of information on exactly what\how
> SpamAssassin matches the RegEx rules when scanning and what variant
> of RegEx is being used?(I.E what syntax is and is not allowed?)


 Perl  

Re: SA RegEx Rules

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Sat, 2009-06-27 at 16:56 +0930, Cory Hawkless wrote:
> Been doing some reading on RegEx and even coming from a programming
> background it is a bit intimidating, my problem is I haven’t been able
> to find a good source of information on exactly what\how SpamAssassin
> matches the RegEx rules when scanning

Depends on the rule type you use. See the Rule Definitions section in
the docs [1] and the Rule Writing intro guide [2] in the wiki.

Between header, uri, body, and the other body rules, the scope of
matching varies significantly. The type of rule also may have an impact
on how the data is rendered (or not).

> and what variant of RegEx is being used?(I.E what syntax is and is not
> allowed?)

Perl Regular Expressions. The perlre [3] docs are quite heavy and best
used as a comprehensive reference, though. For some gentle introduction
and a longer tutorial, see the links in the Description section of [3].


> I’d like to be able to make my own simple rules but it’s proving quite
> difficult, Maybe a tool that I can use the build Regular Expressions
> would help? 
> 
> I’m sure there are PELNTY of other out ther that are rather bamboozled
> by this also and would benefit greatly from any assistance.

Besides writing your own custom rules -- this list is a good source for
general advice, and ready-made rules targeting new spammer patterns. I
suggest checking the (recent-ish) archives and lurking on list. You can
learn and catch a great lot by that.

  guenther


[1] http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Conf.html
[2] http://wiki.apache.org/spamassassin/WritingRules
[3] http://perldoc.perl.org/perlre.html

-- 
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}


RE: SA RegEx Rules

Posted by Martin Gregorie <ma...@gregorie.org>.
On Sun, 2009-06-28 at 09:01 +0100, richard@buzzhost.co.uk wrote:
> On Sun, 2009-06-28 at 11:23 +0930, Cory Hawkless wrote:
> > Ahh, I have played with regexbuddy but when copy and pasting the SA
> rules in it does strange things that are inconsistent with the result
> i get from SA, These recent shopxx rules have been good examples but I
> cant get regexbuddy to reproduce the expected results?
>
Unfortunately regular expression syntax isn't standard - there are at
least two common C libraries floating around and then there are the
variations used by awk, bash, expr, grep, Java, Perl, ......

Some simple regex expressions should give the same results everywhere
but anything that's a little more complex probably won't. For instance,
grep uses a separate option to set case insensitivity while Perl uses
the /../i suffix.

So, just a thought - I've never used RegexBuddy so have no idea how good
it is or if you can configure its default syntax, but do you always tell
RegexBuddy that you're using Perl regexes?


Martin



RE: SA RegEx Rules

Posted by "richard@buzzhost.co.uk" <ri...@buzzhost.co.uk>.
On Sun, 2009-06-28 at 11:23 +0930, Cory Hawkless wrote:
> Ahh, I have played with regexbuddy but when copy and pasting the SA rules in it does strange things that are inconsistent with the result i get from SA, These recent shopxx rules have been good examples but I cant get regexbuddy to reproduce the expected results?
> 
> Has anyone used regexbuddy before?
> 
> -----Original Message-----
> From: richard@buzzhost.co.uk [mailto:richard@buzzhost.co.uk] 
> Sent: Saturday, 27 June 2009 5:12 PM
> Cc: users@spamassassin.apache.org
> Subject: Re: SA RegEx Rules
> 
> On Sat, 2009-06-27 at 16:56 +0930, Cory Hawkless wrote:
> > Hi all,
> > 
> >  
> > 
> > Been doing some reading on RegEx and even coming from a programming
> > background it is a bit intimidating, my problem is I haven???t been able
> > to find a good source of information on exactly what\how SpamAssassin
> > matches the RegEx rules when scanning and what variant of RegEx is
> > being used?(I.E what syntax is and is not allowed?)
> > 
> >  
> > 
> > I???d like to be able to make my own simple rules but it???s proving quite
> > difficult, Maybe a tool that I can use the build Regular Expressions
> > would help?
> > 
> >  
> > 
> > I???m sure there are PELNTY of other out ther that are rather bamboozled
> > by this also and would benefit greatly from any assistance.
> > 
> >  
> > 
> > Thanks in advance
> > 
> > Cory
> > 
> >  
> http://www.regexbuddy.com/
> 
> 
I've used it, but I don't rate it much if I'm honest. It's great for
beginners to get an 'idea' hence posting the link. I do most of my
testing either with VIM (VI is a bit too old school for me) or gedit
with the regex search and replace plugin.


RE: SA RegEx Rules

Posted by Cory Hawkless <co...@hawkless.id.au>.
Ahh, I have played with regexbuddy but when copy and pasting the SA rules in it does strange things that are inconsistent with the result i get from SA, These recent shopxx rules have been good examples but I cant get regexbuddy to reproduce the expected results?

Has anyone used regexbuddy before?

-----Original Message-----
From: richard@buzzhost.co.uk [mailto:richard@buzzhost.co.uk] 
Sent: Saturday, 27 June 2009 5:12 PM
Cc: users@spamassassin.apache.org
Subject: Re: SA RegEx Rules

On Sat, 2009-06-27 at 16:56 +0930, Cory Hawkless wrote:
> Hi all,
> 
>  
> 
> Been doing some reading on RegEx and even coming from a programming
> background it is a bit intimidating, my problem is I haven???t been able
> to find a good source of information on exactly what\how SpamAssassin
> matches the RegEx rules when scanning and what variant of RegEx is
> being used?(I.E what syntax is and is not allowed?)
> 
>  
> 
> I???d like to be able to make my own simple rules but it???s proving quite
> difficult, Maybe a tool that I can use the build Regular Expressions
> would help?
> 
>  
> 
> I???m sure there are PELNTY of other out ther that are rather bamboozled
> by this also and would benefit greatly from any assistance.
> 
>  
> 
> Thanks in advance
> 
> Cory
> 
>  
http://www.regexbuddy.com/



Re: SA RegEx Rules

Posted by "richard@buzzhost.co.uk" <ri...@buzzhost.co.uk>.
On Sat, 2009-06-27 at 16:56 +0930, Cory Hawkless wrote:
> Hi all,
> 
>  
> 
> Been doing some reading on RegEx and even coming from a programming
> background it is a bit intimidating, my problem is I haven’t been able
> to find a good source of information on exactly what\how SpamAssassin
> matches the RegEx rules when scanning and what variant of RegEx is
> being used?(I.E what syntax is and is not allowed?)
> 
>  
> 
> I’d like to be able to make my own simple rules but it’s proving quite
> difficult, Maybe a tool that I can use the build Regular Expressions
> would help?
> 
>  
> 
> I’m sure there are PELNTY of other out ther that are rather bamboozled
> by this also and would benefit greatly from any assistance.
> 
>  
> 
> Thanks in advance
> 
> Cory
> 
>  
http://www.regexbuddy.com/


Re: SA RegEx Rules

Posted by mouss <mo...@ml.netoyen.net>.
Cory Hawkless a écrit :
> Hi all,
> 
>  
> 
> Been doing some reading on RegEx and even coming from a programming
> background it is a bit intimidating, my problem is I haven’t been able
> to find a good source of information on exactly what\how SpamAssassin
> matches the RegEx rules when scanning and what variant of RegEx is being
> used?(I.E what syntax is and is not allowed?)
> 

spamassassin written in perl, so it uses perl syntax.
>  
> 
> I’d like to be able to make my own simple rules but it’s proving quite
> difficult, Maybe a tool that I can use the build Regular Expressions
> would help?
> 


IMHO, the best tool is to learn perl syntax. you can for example look at
chapter 6 in the "Perl Cookbook".

here are a few links returned by google:
	http://www.perlfect.com/articles/regextutor.shtml
	http://www.anaesthetist.com/mnm/perl/Findex.htm#regex.htm
	http://www.cs.tut.fi/~jkorpela/perl/regexp.html
	http://www.troubleshooters.com/codecorn/littperl/perlreg.htm


>  
> 
> I’m sure there are PELNTY of other out ther that are rather bamboozled
> by this also and would benefit greatly from any assistance.
> 
>  
> 
> Thanks in advance
> 
> Cory
> 
>  
> 
>  
>