On 17 May 1999, Tony Lam <Tony(_dot_)Lam+procmail(_at_)Eng(_dot_)Sun(_dot_)Com>
I'd like to do some subject cleaning with procmail so that:
Subject: [Fwd: Re: misc stuff] => Re: misc stuff (fwd)
Subject: Re: [Fwd: Re: misc stuff] (fwd) => Re: misc stuff (fwd)
Subject: [Fwd: [Fwd: Re: [ace-users] misc stuff] ] => Re: [ace-users] misc
I have the following recipe that only handles the first case:
I need help to get it work with case 2 and 3? Note the [Fwd: .* ] can
be multi-level nested. It doesn't look easy for me.
It isn't. As usual, the problem is there's no way to tell procmail
to stop adding characters to $MATCH when it hits a certain pattern.
That's why your best bet is to do the whole thing with sed:
* ^Subject:[ ]+\/.*\[Fwd:.*
subj = `echo $MATCH | sed \
-e 's/^\(\(\[Fwd\|Re\):[ ]*\)*/Re: /' \
-e 's/\(\][ ]*\|[ ]*(fwd)\)*$/ (fwd)/'`
| formail -I "Subject: $subj"
Basically, the first command replaces the leading "[Fwd:" and "Re:"
by a single "Re: ", and the second one replaces the trailing "]" and
"(fwd)" by a single " (fwd)". No attempt is made to count the "[" and
match them to the right.
Dr. Liviu Daia e-mail: Liviu(_dot_)Daia(_at_)imar(_dot_)ro
Institute of Mathematics web page: http://www.imar.ro/~daia
of the Romanian Academy PGP key: http://www.imar.ro/~daia/daia.asc