<<< Date Index >>>     <<< Thread Index >>>

Re: index_format filtering?



On 12:49 18 Jan 2004, Patrick Shanahan <WideGlide@xxxxxxxxxxxxx> wrote:
| > | > I do this in my procmailrc with this rule:
| > | >         # tidy up Re: and [tag] in Subject:
| > | >         :0 Whf
| > | >         * ^subject:.*(\[|re)
| > | >         | cleansubj
| > | > where cleansubj is this script:
| > | >         http://www.cskk.ezoshosting.com/cs/scripts/cleansubj
| > | 
| > | Tried your script and like the idea, but the following fails and I have
| > | *no* knowledge of sed *^(
| > |    Re: [[some-text] Original Subject]
| > | result:   Original Subject]
[...]
| > Before I could fix this, what did you _want_ it to end up with?
| The trailing ']' removed.  thanks

Try the attached version. Looks ok at this end.
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Your mouse has moved. Windows NT must be restarted for the change to take
effect. Reboot now?  [ OK ]     - John D. Hardin <jhardin@xxxxxxxxxxxx>
#!/bin/sed -f
#
# Tidy up Subject: lines.
# Strip multiple Re: stuff and [list] tags.
#       - Cameron Simpson <cs@xxxxxxxxxx> 14feb2002
#

:top
s/^[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:[       ]*//
t subject
n
b top

:subject
# clear the hold space
x
s/.*//
x

:strip
# strip leading whitespace
s/^[    ][      ]*//
t strip
# strip trailing whitespace
s/[     ][      ]*$//
t strip
# strip [foo] -> foo (suggestion from Patrick Shanahan)
s/^\[[  ]*\(.*\)\]$/\1/
t strip
# strip leading [nonwhite]
s/^\[[^         ]*\]//
t strip

# last check: a "re:"?
/^[Rr][Ee]:/!b finish
# we have a leading "re:"

# place a "re:" to the hold space
x
s/.*/Re:/
x

# strip leading "re:"
s/^[Rr][Ee]:[   ]*//
t strip

:finish
# insert hold space at start of line ("" or "Re: " depending on what we saw)
H
x
s/\n/ /

s/^/Subject: /