procmail
[Top] [All Lists]

Re: Matching questions - regexp

2000-09-26 15:04:26
Tom wrote ...

well, I can't go through it all, but there's one thing that might be key
here: procmail is austere in matching text in messages to wildcards in
regexps to the left of \/ (or in the absence of \/) but greedy to the right
of \/.

So when you have something like,

  * ^Subject:[  ]*\/.+

where there is a space immediately after the colon in the actual message,
procmail is very happy to match "zero or more spaces or tabs" to zero spaces
or tabs (austere left of \/) and include the space as part of ".+".  To avoid
that, you need to do something like this:

 * ^Subject:[   ]*\/[^  ].*

so that the right side of the expression must match a string that starts with
a character that isn't a space nor a tab (nor a newline).

| What does [^  ].* mean as opposed to .*  ??

The first means any character that is not a space, a tab, nor a newline, plus
zero or more following characters that are not newlines.  The second means
any string of zero or more non-newlines.  The second can be null, or can
start with a space or a tab; the first must have at least one character, and
its first character may not be a space, a tab, nor a newline.


_______________________________________________
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>