procmail
[Top] [All Lists]

Re: Regex question.

1998-01-12 01:28:46
On Sun, 11 Jan 1998 22:56:36 -0800, John Conover <conover(_at_)netcom(_dot_)com>
wrote:
What does the (.*[^a-zA-Z])?) do in:
    * (^(To|Cc|Bcc):(.*[^a-zA-Z])?)someone(_at_)somewhere

The intent is apparently to anchor the match before the address.
Unless you have special needs, just could probably just resort to

    * ^TO_someone(_at_)somewhere

(that's right, no colon or wildcard anywhere; use ^TO instead of ^TO_
if your version of Procmail is ancient [as the case may be on Netcom])

/* era */

If you are unfamiliar with regex syntax, .* skips any number of
characters but [^A-Za-z] forces the last skipped character to be
nonalphabetic, i.e. bounds the extent of the skip. This is slightly
stupid, as you should at least disallow numbers, too, but if the
address you're matching on is really "someone(_at_)somewhere", the chances
of an accidental match on "1someone" are extremely small and so
probably something you can live with. OTOH, the correct solution is
actually less typing: (.*\<)?

The second closing paren, which you included in your question, is not
part of the bounding expression, but rather serves to group the two
inner sets of parentheses -- the first containing To, Cc, and
(slightly inexplicably) Bcc, and the second containing the bounding
expression discussed here.

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

<Prev in Thread] Current Thread [Next in Thread>