procmail
[Top] [All Lists]

Re: matching variables

2001-12-06 07:55:57
Nico asked,

| a) I'd like to filter out all e-mails containing "Ed" either in the header
| or the subject line.

The subject line is part of the header, so a search of the header will
include the subject line.

| Since .*ed would match a *lot* of words,

... including "Received:," so every message you'd get would match if didn't
narrow it ...

| I was thinking of using \<ed\>.
| Would the latter way work?

Yes.

| Or maybe I can avoid the trouble of matching to
| much by insisting procmail to look on case-sensitive.

You wouldn't want to match on "Educational" either, so if the "Ed" you are
looking for will always be capital E, lower-case d in a word by itself, use
both the `D' flag and the word delimiters.

| BTW, would \<ed\> be sufficient or .*\<ed\> ?

Regexps, unlike shell globbing patterns, are unanchored by default, so ".*"
changes nothing except to slow procmail down a little.  However, leading
backslashes are problematic, the best way is this:

 :0D
 * ()\<Ed\>
 action

| b) If I scan the body, the "varible" line, like any other "variable" line,
| starts with an asterisc *. Can I do the following:
| * .*(goofy|micky) or will the .* right after * cause confusion?

You mean it starts with a literal asterisk that you want to find in the
text?  OK ...

.* means "any string without a newline, possibly a null string."  That's not
the same as a literal asterisk.  To match a literal asterisk, you need \*
with a backslash to defuse the usual special meaning an asterisk has in a
regular expression.  To start a procmail regexp with a backslash, you
need -- well, let's just say that an empty pair of parentheses is the
easiest way to get around that problem.  So to match either "*goofy" or
"*micky" (as in Goofy and Mickey Mouse?) it's

 * ()\*(goof|mick)y



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