procmail
[Top] [All Lists]

Re: Regular Expression Misunderstanding

1998-11-28 05:26:49
On Fri, 27 Nov 1998 18:49:28 -0800 (PST), Shoeless in San Jose
<batchman(_at_)slip(_dot_)net> wrote:
On Fri, 27 Nov 1998, David W. Tamkin wrote:
Era Eriksson commented on Adam Bailey's reply to whoever had originally
asked the question ... 
|     :0:
|     * (^From:|^TO_)(.*\<)?someaddress\>
|     somefolder
Rather than muck with the matching in ^TO_, I'd suggest this:
* (^From:(.*\<)?|^TO_)someaddress\>

(Of course!)

| or even just
|     :0:
|     * ^(From|To)(.*\<)?someaddress\>
|     somefolder
The problem there is that you lose matching on Cc:, Resent-To:, and such
other lines that ^TO and ^TO_ would catch. 

(That was sort of a point I was trying to make -- sometimes you really
do want to look at only To:, especially if you seem to be content with
matching only From:, and not Resent-From: etc. Of course, as Greg (*)
suggests, it might as well be the other way around.)

(*) not sure here, it's not entirely clear from his [?] message ... The
From: line would suggest that his [?] first name is Shoeless ;-)

Here's the version I use that I downloaded from Martin Ramsch's page
(http://www.forwiss.uni-passau.de/~ramsch/Software/ef2p/index.phtml.en):
<...>
Then, as an example, here's the syntax of how it's used:
:0:
* EF2P_FROM ?? (_dot_)*batchman(_at_)slip\(_dot_)net
$MAILDIR/TEST
My question is...does that cover everything, or should I add / modify it?

The .* wildcard is certainly always to be avoided in these
circumstances, especially if you use your recipe as some sort of
library plug-in or similar. The regular expression used in ^TO_ is
reasonably sure to always skip comments etc up to the actual address,
so you might want to craft your FROM variable based on that instead
(or perhaps define both FROM and FROM_ to go with ^TO and ^TO_). 

The actual regular expression used by Procmail is spelled out in the
procmailrc(5) manual page.

Otherwise, (.*\<)? is a somewhat more cautious -- but by no means good
-- replacement for just .*

Hope this helps,

/* era */

-- 
.obBotBait: It shouldn't even matter whether    <http://www.iki.fi/~era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>

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