procmail
[Top] [All Lists]

Re: 's and Fwd's

2001-06-23 13:52:11
"S.Toms" <smotrs(_at_)mindspring(_dot_)com> writes:
...
 Anyway, I'm trying to come up with a recipe that will deal with all the
re's and fwd's that appear in the subject line

   Subject: Re: Re: Fwd: re: identd

a previous post a while back gave me the idea and this is what I've got so
far

   :0
   * ^Subject: (Re|Fw|Fwd):.* \/.*
   {
      CURSUBJECT="$MATCH"
      CURSUBJECT=`echo $CURSUBJECT | sed s/.R\[Ee\]://g`
      CURSUBJECT=`echo $CURSUBJECT | sed s/.F\[Ww\]://g`
      CURSUBJECT=`echo $CURSUBJECT | sed s/.F\[Ww\]\[Dd\]://g`

      :0f
      | formail -I"Subject_New: $CURSUBJECT"
   }

but I'm wondering if there's a way to have it leave what ever the last
mail operation was, the one directly after the subject, so that it would
say

   Subject: Re: identd
        or
   Subject: Fwd: identd

depending on whatever the last mail operation was.
...


How about the following?

        # We only have to do something if there are at least two in the subject
        :0
        * ^Subject: *(Re|Fwd?): *\/(Re|Fwd?):.*
        {
                # Strip Re:, Fw: and Fwd: bits from the extracted text
                NEWSUB = "`echo $MATCH | \
                        sed -e 's/[rR][eE]: *//g' \
                            -e 's/[fF][wW]: *//g' \
                            -e 's/[fF][wW][dD]: *//g'`"

                # Extract the leading bit and put the new subject in
                :0
                * ^Subject: *\/(Re|Fwd?): *
                | formail -I "Subject-New: $MATCH$NEWSUB"
        }

Note that the above will remove Re: and the like from the _middle_ of
the subject.  Removing only leading ones requires more sed hackery than
I know, or a switch to perl or awk.


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