procmail
[Top] [All Lists]

Re: Need help demunging Subject header

2002-08-29 14:58:10
Thanks to all for your help.  Bart's suggestion was not exactly what I 
needed, since "Re:" does not always appear.  What I finally came up with is:

FRONT=

:0
* ^Subject:\/([^[])+
{ FRONT=$MATCH }

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


This seems to work, except for leaving an extra space in the Subject when it 
removes "[something]".  For example:

Subject: [something] Here is the subject
        ^           ^
becomes:

Subject:  Here is the subject
        ^^

The alternative is failing to match when "[something]" is not surrounded by 
spaces (probably because I do not fully understand \/.)

Can anyone see a problem with this recipe?  And is there a way to get rid of 
the extra space?  If not, I am very willing to live with the current behavior.

-- 
Jim McMaster
mailto:mcmasjc(_at_)tatanka(_dot_)stortek(_dot_)com


In message 
<Pine(_dot_)LNX(_dot_)4(_dot_)44(_dot_)0208281138590(_dot_)28602-100000(_at_)aztec(_dot_)zanshin(_dot_)com>,
 Bart 
S
chaefer said:
On Wed, 28 Aug 2002, James C. McMaster (Jim) wrote:

Several misguided mailing lists add a "[identifier] " token to their
Subject:  headers to make their lists "easy" to use.  One list I am on
just added a very long id, which is annoying enough I want to get rid of
it with procmail.

Something like this should do it:

 RE=

 :0
 * ^Subject: \/(Re: |\[[^]]+\] )+
 * MATCH ?? ()\/(Re: )
 { RE=$MATCH }

 :0fhW
 * ^Subject: (Re: |\[[^]]+\] )+\/.*
 | formail -I"Subject: $RE$MATCH"

You can probably figure out how to adjust it for UAs that do stupid things
like 'Re[2]:' and other prefixes like "Fw:" or "(Fwd)".



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