Right, you can make an entire word optional by "grouping" it (enclosing it
in parentheses) and marking the group as optional by tacking a question
mark on the end.  In your case (a single character) it is better to use
one of the other examples where you mark either a character class that
only matches a space "[ ]?" or just the space itself " ?" as optional.


You can use groupings to denote alternates as well (this is where they
become quite useful), such as:

body LOCAL_FREE_DRUGS /(free|cheap)\s+(drugs|herbs)/i

which matches
"free drugs"
"cheap drugs"
"free herbs"
"cheap herbs"

In perl, a grouping that starts with "?:" doesn't capture the matching
text.  You basically can't do anything with captured matches in
SpamAssassin, so add the ?: to reduce overhead:

body LOCAL_FREE_DRUGS /(?:free|cheap)\s+(?:drugs|herbs)/i

HTH


--
Chris Thielen

Easily generate SpamAssassin rules to catch obfuscated spam phrases:
http://www.sandgnat.com/cmos/



ian douglas said:
>> did you mean:
>> rawbody  W98_UNSUBSCRIBE4  /prefer not to(?: )?see/i
>> Better yet:
>> rawbody  W98_UNSUBSCRIBE4  /prefer not to[ ]?see/i
>> or even:
>> rawbody  W98_UNSUBSCRIBE4  /prefer not to ?see/i
>
> Ah, didn't know I needed a trailing ? after the set of parentheses, I
> thought the syntax was only (?:MatchSomethingThatMayOrMayNotBeHere)
>
> So I should have it as
>
> (?:MatchSomethingThatMayOrMayNotBeHere)?
>
> then?
>
> -id



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to