procmail
[Top] [All Lists]

Re: No match on Invalid recipient:

2001-09-03 00:59:44
On  3 Sep, Tim Rice wrote:
| [...]
| Rather than just cut & paste your previous code, I'd like to understand how
| it works. I follow the bulk of it <thanks to your and others previous
| postings>, but I'm confused on the *<? before the \/ match. What is that
| part doing?
| 
| 
| * B ?? ^Invalid recipient:[     ]*<?\/[^<>      ]+
| 

Good idea to not blindly cut & paste.  The * in a regular expression
says zero or more of what precedes it. Here that's a character class
(everything between []) encompassing a space and a tab. So following the
colon, it says look for zero or more (of any combination of) spaces
and/or tabs. The ? says zero or one of what precedes it. Here that's a
<, so it's making that character optional.  After that, is the match
operator \/ which you know is internal to procmail and says capture
everything that follows and assign it to the variable $MATCH. And what
follows is a negated (first character ^) character class that includes
<, >, space, and tab. So anything that is not one of those 4 characters
will match. The trailing + says at least one or more of those
characters. Because the procmail regular expression engine is "greedy"
to the right of the \/ operator (it'll match as much as it possibly
can), you capture everything up to, but not including, the > (whether
it's there or not) of the email address. To confuse matters further
<g>, the < needs to be in the negated character class because procmail
regular expressions are not greedy to the left of the match operator. If
the email address did include the <> pair, the <? would cause it to show
up in $MATCH if it weren't excluded like this. 

-- 
                   /"\
Don Hammond        \ /     ASCII Ribbon Campaign
Raleigh, NC US      X        Against HTML Mail,
                   / \      and News Too

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