procmail
[Top] [All Lists]

Re: block mail by compairing word in subject

2005-04-29 04:07:15
On Thu, 28 Apr 2005 10:39 pm, Dallman Ross wrote:
On Thu, Apr 28, 2005 at 09:39:15PM +1000, Peter Jones wrote:
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...

That's not what I meant by "rightward-greedy."  (And I hope you
saw my follow-up list mail explaining a bit more about that.)

No, obviously not! :-)

I read what you wrote, then I read your follow-up, and it just didn't 
click what you were saying (and I thought "well, I guess procmail just 
handles its regexes differently from what I'm used to...")  Even after 
writing out my reply (and reading over it all again before sending) it 
didn't click.

Then I got home tonight, and as soon as I saw this email from you sitting 
in my mailbox (even before I read it) this huge flashbulb went off in my 
head and I realised how completely I'd misread your first email!

d'oh!

So, sorry for the confusion, and I realise now what you were saying (and 
that we were speaking of two different "+" modifiers; you meant the first 
one, I was looking at the second!)

Look:

Yeah, thanks for the effort you put into setting me right; I do appreciate 
it!

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

Well, yes, there is.  For example, if we are looking for leading
words such as "RE:" in a subject line, and so on.

True.  (I was really mis-firing last night, it seems!)

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.)

You don't need to change it for that reason.  It will match a one-
letter subject.  Let's test it:
[snip]
The regex "+" matches "one or more."  One is enough.  It will
be matched.

But if I'm reading your email correctly (and anything is possible at this 
point) the pattern you are using in test2.rc is this one:

* $ SOMEHEADER ?? :.*\/[^$SPACE].*

which sets $MATCH to [first_nonspace_character] followed by .* (which can, 
of course, match [nothing].)  That was why I was talking about changing 
from your original version which was (from your earlier letter):

So let's just grab any Subject starting with the first
non-whitespace character, shall we?

  * ^Subject:.*\/[^     ].+

which matches [first_nonspace_character] followed by "one or more" -- 
which is at least two characters total.

I'll let someone else tackle that one.

Ruud did.  Thanks!  :-)  (And see my reply to him for more on that...)

Okay, but I wouldn't use what Michelle does as a litmus test
for what's possible without perl.

Well no, I guess not -- since it obviously can be done with egrep!  It was 
more the case that I was already thinking I'd have to write a perl 
script, and when the first response was Michelle with her bash solution, 
it was enough to give me the nudge to dive into perl...  (One of my big 
character flaws is my continual need to reinvent wheels! :-))

Cheers,
Pete.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail