procmail
[Top] [All Lists]

RE: I can't explain this, it's just weird!

2007-06-05 16:53:30
What you probably want for your condition is this:

     * $ ^X-Original-To:.*\/[^(_at_)$WS]+

That will start the match at the first non-whitespace char.

I don't understand that, but I know I should from your
explanation about least bit greedy before the match.  This is
how the regex and match reads to me...

- Match as little as you can before \/, so try and match any
character 0 times.  - Oh goody, here's \/ - let's get greedy.

:-)  So far, so good.

- Match as much as you can until you come to a whitespace or @
char.

Nope.  Let's back up.  You originally had:

  * ^X-Original-To:[$WS]*\/[^(_at_)]+

Do you see that the part in brackets -- which designate a
character class -- means "NOT an '@' symbol"?  The leading
caret in a char class means "NOT (any of the class members)."
You wanted to match the local part of an email address, such
as matching on "dman" given my full address as shown above.
So you matched on any char that is not a "@".  The match
succeeds until it gets to a "@", and then it stops matching.
The first character it matched was a space, for the reasons
cited in my previous article.

Okay, so if we add things to the class, the NOT is still
there.

   * [^(_at_)ABC]

means "NOT @ or A or B or C".  (The match will not be
case-sensitive, though!  We'd need the D-flag on
the recipe for that.

   * $ [^(_at_)ABC$WS]

Now we have "NOT @ or A or B or C or whitespace."
(Notice the leading $ now, needed to expand the var 
inside the char class.)

Okay, so

   * ^Header:.*\/[^$WS(_at_)]+

means "after the left-anchored header, start matching
at the first non-whitespace, non-@ character and move right
until we reach either a @, whitespace, or the end of the line.
Save what we get to the MATCH variable."

Dallman
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail