procmail
[Top] [All Lists]

Re: matching subjects with words in []

1997-01-25 15:58:40
Philip Guenther asked Jeffrey Covey,

| So, what _did_ you try?

My guess is that, if Jeff came across his question in the first place, he
must have tried just

   * \[MAC\]

and procmail took the first backslash to mean "regexp will start with next
character" instead of "invert default magic of next character."  If he had
used

  * ^Subject:.*\[MAC\]

as several people have recommended, his attempt to escape the left bracket
to match a literal bracket in the text would have worked.

My suggestion is that Jeff include the field name in the condition, since
there is no reason to make procmail search the entire header if only the
subject line matters to the condition.  If he really wanted to search for
[MAC] anywhere in the head though, the following epitome of counterintui-
tion would do the job, as much as we tend to think of "\\" as meaning a
literal backslash:

  * \\[MAC\]

In fact, if the left bracket is successfully escaped, we don't need to
escape the right bracket.  Actually, if someone really wanted to look for
[MAC] anywhere in the head,
 
  * ()\[MAC]

is probably the best way to write it.