> >> I am trying to write a negative scoring rule that files on the > >> following: PO > >> PO# > >> PO # > >> > >> Following is the rule I am using: > >> > >> header PO_AND_ORDERS Subject =~ /\bPO*?#?/i
In REs, the asterisk '*' is a quantifier, not a wildcard as it is with the shell, and means "zero or more occurrences". So /PO*/ will match a plain 'P', too, just like 'POOO'. (To complicate things, the *? means "as little as possible while still matching the RE", but we better ignore that for now. ;) Btw, you need to escape the hash '#', not because this is an RE, but because it is Perl. :) Might I suggest reading some introduction about Regular Expressions first, before trying to write more of them? http://perldoc.perl.org/perlre.html The Perl RE Reference seriously will be overkill and explains more than you ever would want to know. Have a look at the quick-start introduction and the tutorial linked in the first paragraph there. The Reference itself might still be useful as, well, a reference. ;) > Sometimes the subject will be: PO#34598459 so do I realy want to us \b? Yes. A word boundary \b does not mean "space", but a (zero-width) transition from a word char \w to a non-word char \W. Word chars are alphanumerical plus the underscore, non-word chars are anything else. Maybe something like this? This requires an actual number, with either combination of spaces and an optional hash between PO (case sensitive, upper case only) and the number. /\bPO *(\# *)?\d/ > I need to match all of the ollowing: > PO > PO# > PO [0-9] - im not sure the max amount of numbers > PO# [0-9] - im not sure the number of numbers > PO[0-9] - not sure how many numbers > PO#[0-9] - not sure how many numbers That's easy. /\bPO\b/ will do -- might hit on spam as well, though, since it is really short. Please note that you do *not* need to specify all variations explicitly, if you actually want to match *anything* that starts with "PO"... -- char *t="[EMAIL PROTECTED]"; 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; }}}