procmail
[Top] [All Lists]

Re: procmail regex

2002-02-15 13:27:53
You not being mean.  

I thank you for the help. And your right - I changed
what I said.  The problem was origianlly spammers
with just capital letters.  Then is was

Subject: some message like this                   SECRETCODE



BTW - I learned
C, Shell, Grep, Sed, and last Perl.
(and then C++, AWK, TCL, GTK :-)

In that order.  But I'm much better at perl at this point.


Ruben originally wrote,

I'm trying to capute all messages consisting of only upper case letters in
the subject ...

but in a follow-up he said something else:

| I'm saying I want anthing followed by at least 1 or more capital letter at
| the end
| Like this

| Subject dfhhjsd klfshjfs jklfsdfsjkl JKDSDHJFDDF

First, since that's supposed to be a header line, I assume you meant

  Subject: dfhhjsd klfshjfs jklfsdfsjkl JKDSDHJFDDF

Ruben, I don't intend to be mean, but your careless typing is not helping.
We can figure out what "capute" and "anthing" are supposed to be, but when
it comes to clips of your code or nonsense words that you use as examples,
where almost any text could be what you mean, you can't make it our job to
guess.

One problem is that any casing of "Subject:" is allowed; we'll have to deal
with that.  Another is that, because you learned perl first, you're
demanding that everything else be exactly like perl; you'll have to let go
of that.

One good way to consider case only after the colon is to extract what's
after the colon and examine it separately, as in the snippet of code I wrote
in a similar discussion, as Sean just quoted:

 :0
 * ^Subject:\/.+
 {
  SUBJECT=$MATCH

  :0Diw
  * MATCH ?? [A-Z]$
  |/home/ruben/complain.pl
 }

Note that making sure the string ends with a capital letter is the same as
making sure that it ends in one or more capital letters but surely is more
efficient for procmail's regexp engine.  Also, because you care only about
the last character of the subject, we don't have to make special rules for
"Re:" as with the problem of looking for subjects with all capitals.

If you want to look for subjects where the last word is wholly capitalized
(what if it's an acronym that *should* be fully capitalized, though, rather
than just the screamlock of advertising hype?), I'd say to use this instead
(with the `D' flag, of course):

  :0Diw
  * MATCH ?? ()\<[A-Z][A-Z]+$
  |/home/ruben/complain.pl

I deliberately required at least two capital letters there, so that the
presence of just one closing capital (such as "Your child is getting an F"
or "Nobody is as happy as I") won't trigger it.


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