procmail
[Top] [All Lists]

Re: Need help demunging Subject header

2002-08-29 15:52:40
At 15:41 2002-08-29 -0600, James C. McMaster (Jim) wrote:

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

Why "one or more" closing brackets? For that matter, why the parens around the regexp?

Have you tried:

:0fhW
* 9876543210^0 ^Subject:.*\[[^]]+\][    ]*\/[^  ].*
* 9876543210^0 ^Subject:.*\[[^]]+\][    ]*\/
| formail -I"Subject:$FRONT$MATCH"

The first one will typically match on anything where there IS a subject line (not just the banner), and the second should match blank subjects (basically, it'll allow you to consistently strip it when it's the only text - or appears AFTER the true subject or whatever). Only one of them needs to match, and THAT one will have set the $MATCH variable. Yes, they eat MULTIPLE whitespace trailing the bracket text, not just one. Munching a single optional whitespace is left as an exercise for the reader.

After writing this, but before having emptied my queue, I noted Bart's reply - the syntax (minus scoring) is the same as the first of the two above - but will fail whenever the subject is blank following the bracketed tag.


Keep in mind that since your overall approach doesn't anchor to the beginning of the subject with blank/re/fwd text only, it will happily mangle subjects such as:

"How do I remove [listname] type markers?"

In fact, some lists I'm on actually use these sorts of markers ENTERED BY THE AUTHORS to signify certain broad topics which members may want to skip - [POLITICS] [NEWS], etc.

Crossposted messages - topics started on one list and posted over into another will frequently have two banners:

        Fwd: [currentlist] Re: [originallist] topic

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail