procmail
[Top] [All Lists]

Re: Filter Question (really regexp question)

2002-01-26 16:09:31
Tim Holmes has this code:

| # This filter is for all mail I send myself.
| :0:
# wrapped by me (DWT) to keep my MUA from chewing it up:
| *^From:.*(tim(h)|tdh)@(domain1.com|domain2.com|\
  domain1.net|domain1.org|domain2.org)
| tdh

You really ought to escape those periods in the domain names, but let's get
to your question:

| My main email address is timh(_at_)domain1(_dot_)net(_dot_)  But I also have 
another email
| address that I use for consulting etc; which is this email address,
| tim(_at_)unixtechs(_dot_)org(_dot_)
|
| I *THOUGHT* I could just use tim(h) to capture timh(_at_)domain1(_dot_)com and
| tim(_at_)unixtechs(_dot_)org(_dot_)  But it doesn't seem to work that way.  I 
have both
| domains specified in my filter.

If you want to catch both tim and timh, it's  timh?  where the question mark
means "zero or one of the preceding element" or "the preceding element or
nothing at all" or "optionally, one of the preceding element."  For just one
character you don't need the parentheses, but if  tim(h)?  is more readable
for you, go ahead.

Parentheses don't make something optional: rather they bound an element when
it is greater than a single character or a single bracketed class, or they
delimit an alternation.

The only trouble with alternating the local parts separately from the
domains is that you'll also be matching tim(_at_)domain1(_dot_)com and
timh(_at_)unixtechs(_dot_)org and every other possible combination.  I recommend
alternating whole addresses for this purpose and not trying to swivel around
the @-sign, though certainly any overlapping part can be pulled out, as in
tim(h(_at_)unixtechs\(_dot_)org|@domain1\.com), as long as you don't create 
extra
matches.

DWT (goes by "dattier" everywhere and could safely swivel on the @)


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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