On Thu, 28 Apr 2005 01:14 am, Dallman Ross wrote:
Since what matches to the right of the `\/' match token is
rightward-greedy, your `+' there is essentially meaningless.
Okay, thanks for that. This is essentially my first time playing with
'\/' so I've obviously got a bit to learn...
So let's just grab any Subject starting with the first
non-whitespace character, shall we?
* ^Subject:.*\/[^ ].+
I guess that "+" would also be unnecessary?
Apparently the "+" *is* required! When I tested my original pattern
without the trailing "+" ("Subject:[ ]+\/.") it set $MATCH to the
first letter of the subject line -- which is how I would have expected it
to behave. It may be rightward-greedy, but a single "." will still only
match one character...
And while, thinking about it, there's actually no particular need to trim
off all the whitespace from the leading edge of the subject, I do like
your approach and shall go with that -- with the minor revision of
changing the final "+" to a "*" on the offchance that I actually ever
want to match a one-letter subject line... (Practically speaking, it
will probably never matter.)
It's not at all clear to me why you would prefer a home-grown
perl call to one of the egrep variants.
I originally tried to use egrep. My blacklist.rc was a variant of a
whitelist.rc which matches valid email addresses. The difference is that
the email address can be extracted in its entirety and an exact match
found in a text file. For subjects, however, we are typically looking
for a substring of the subject, rather than the complete thing -- and,
AFAIK (and I've double checked the man pages to be sure) egrep cannot
perform such a search.
Given "egrep PATTERN FILE", egrep can determine whether any particular
line in the FILE matches PATTERN. What I want to know is whether any
particular line in the FILE is contained within PATTERN... I couldn't
find any egrep option which would do that for me -- hence the PERL
See the list archives and search on "blacklist" and "grep"
When I searched [google], I found quite a few matches for
black/white-listing email addresses -- and nothing for blacklisting
keywords within a subject. (Of course, it probably wasn't a particularly
exhaustive search -- and if this question hadn't appeared on the list
when it did, I might have gone back and searched a little harder; like I
said, though, Michelle's response confirmed what I already suspected...)
procmail mailing list Procmail homepage: http://www.procmail.org/