procmail
[Top] [All Lists]

Re: Detect word

1998-07-27 06:25:33
On Mon, 27 Jul 1998 13:38:56 +0200,
"F(_at_)N" <fan(_at_)galeno(_dot_)unicies(_dot_)cesga(_dot_)es> wrote:
* ^Subject. *damocles

This means: Find Subject, followed by one arbitrary character except
newline, followed by zero or more spaces, followed by the literal
string "damocles".

* ^Subject.... *damocles

This means Subject:, four arbitrary characters, zero or more spaces,
"damocles". 

I wish to find a word in the subject field, but not at the beginning of
the phrase. It can be in any position. 

So you mean you want these to match:

    Subject: about damocles
    Subject: many words and damocles among them

but you don't want these to match:

    Subject: damocles
    Subject: damocles was here
    Subject: Re: damocles was here

If that's correct, how about this? Should it match or not?

    Subject: damocles damocles

If I have this correctly and we decide that the last example should be
allowed to match, try this:

    * ^Subject:[        ]*(Re:[  ]*)?[^         ].*\<damocles\>

This says find Subject, followed by any amount of whitespace (the
characters between the brackets are one space and one tab, in any
order; the star, as usual, means zero or more of the preceding
expression); optionally the string "Re:" followed by more whitespace,
followed by a non-whitespace character, followed by zero or more
characters, followed by a non-alphabetic character, the string
damocles, and another non-alphabetic or newline. (As you may notice,
this actually requires at least two characters before "damocles". As
long as the first one isn't a space, you get a match. So it means you
will get matches on the following, too:

    Subject: : damocles
    Subject: ::damocles

I would imagine that this might not be a big problem in real life.)

If you want to exclude any string starting with "damocles", try this
instead: 

    * ^Subject:[        ]*(Re:[  ]*)?[^         ].*\<damocles\>
    * ! ^Subject:[      ]*(Re:[  ]*)?damocles\>

This will match the same as before, but specifically exclude cases
where there is a "damocles" at the beginning of the Subject: (thus
excluding "Subject: damocles damocles" etc).

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>