procmail
[Top] [All Lists]

Re: Split (\/) regex with optional component on left

2009-12-17 11:26:09
On Wed, 16 Dec 2009, James Michael Fultz wrote:
:0
* ^(List-(Id|Post)|X-(Mailing-)?List):.*<(mailto:)?\/[^(_at_)(_dot_)]+
ML/$MATCH/

So far it works for all except one of the intended matches.  Headers
such as the following:
List-Post: <mailto:listname(_at_)example(_dot_)com>

The trick here is that regex is 'right-greedy'. It will try to make the right most part of the regex ([^(_at_)(_dot_)]+) match as much of the right end of the string as it can, as long as the remaining left side of the regex can match. Therefore the 'mailto:' is NOT matched by the explicit "mailto:"; in parentheses because it is optional, and the 'right-greediest' behaviour is for [^(_at_)(_dot_)]+ to suck up all the characters back to the header colon.

Easiest work around for this, would be to use [^@:.]+ at the end.

- Charles
____________________________________________________________
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