Subject: Re: Help With This Recipe

From: Adam Shostack <[email-masked]>
Date: Wed, 12 Apr 1995 15:43:55 -0400 (EDT)

@* means 'any sequence of ZERO or more @'s.

You want:

* ^Subject: @

This will catch anything with the literal
Subject: @
at the begining of the line.  No need for wildcards, but you could do
it as:

* ^Subject:.*@.* # to catch any subject which includes the @ character.

Adam

| I've got a recipe that I want to use to sort mail from a specific
| mailing list.  Here's how it should ideally work.  Whenever I get mail
| from the list, it should check the Subject.  If the Subject begins with
| a `@' then I know that it's incidental mail and not really list
| related, so I want it automatically trashed, and then I want everything
| else filed.
| 
| Here's what I've come up with:
| 
| :0
| * ^TOmailinglist
| {
|   :0
|   * ^Subject.*@*
|   /dev/null
| 
|   :0 e
|   /mailingfolder/.
| }
| 
| Now of course this doesn't work (if it did, would I be sending mail?). 
| It thinks that everything should be deleted.  So, I'm guessing that the
| wildcard needs to be better defined.  Any suggestions?

-- 
"It is seldom that liberty of any kind is lost all at once."
						       -Hume

---

From: [email-masked] (s.merchant)
Date: 12 Apr 1995 16:31 EDT

>* ^Subject:.*@.* # to catch any subject which includes the @ character.

Careful--I know this was only an example, but the "#" cannot be used as
a comment character in a regular expression since it is treated as a
literal!  I.e., the line above wouldn't match anything that didn't end
with the whole "comment" above.  It's an easy thing to slip up on. :-)

Shahrukh

---

From: [email-masked] (David W. Tamkin)
Date: Wed, 12 Apr 1995 16:15:56 -0500 (CDT)

Jerry Alexandratos wrote,

Adam Shostack has already replied but I disagree in part.  Adam brought up
subjects *beginning* with "@", so perhaps he is on the list that Jerry has
in mind and knows something about it that I don't; then when he dealt with
having the @-sign later in the line, he suggested "^Subject:.*@.*".

The direct explanation is exactly what Adam said: Jerry's expression looks
for "Subject:" at the beginning of the line, followed by anything or nothing
(".*") followed by zero or more @-signs ("@*").  Any letter that has a
Subject: header will meet that criterion and procmail will dutifully drop
it into /dev/null per Jerry's explicit instructions to do so.

I disagree with Adam's recommendation, though.  I'd suggest this:

   * ^Subject:.*@

which looks for "Subject:" at the beginning of the line and an @-sign any-
where later in the line.  If there is more text after the @-sign, it will
still match because the expression is not right-anchored.

I've seen this mistake many times before when people write to the list
asking why their recipes are failing.  They think they're using shell
globbing patterns and need a trailing asterisk in case there are more
characters in the file name.  But FIRST, you do not need to match to the end
of the line (unless you want $MATCH to capture it), and SECOND, asterisks
mean different things in regular expressions from their meaning in shell
globbing patterns: if you do want to match to the end of the line, you need
to use ".*", not just "*".

A trailing ".*" as Adam suggested is non-destructive but unnecessary, and I
believe it slows down the search.

But the trailing "*" _is_ destructive.  It's a bad habit a lot of people got
who-knows-where, like `cat filename |' instead of `< filename'.  Adding that
trailing asterisk never helps and can be harmful.