procmail
[Top] [All Lists]

Re: subject cleaning

1999-05-19 12:18:18
On 19 May 1999, Tony Lam <Tony(_dot_)Lam+procmail(_at_)Eng(_dot_)Sun(_dot_)Com> 
wrote:
"L" == Liviu Daia <Liviu(_dot_)Daia(_at_)imar(_dot_)ro> writes:
[...]
L>     Let's see.  It doesn't work because, unlike your first example,
L> in real life the "]" can be preceded by a space (or "(fwd)" can be
L> followed by a space).  Ok, try this:

L> echo "[Fwd: [Fwd: Re: [ace-users] misc.jet] (fwd) ] (fwd)" | sed \
L>    -e 's/^\(\(\[Fwd\|Re\):[        ]*\)*//' \
L>    -e 's/\([       ]*\][   ]*\|[   ]*(fwd)[        ]*\)*$//'

Is it that my sed works different than yours?

    Well, I wouldn't rule out that possibility, some OSes are known to
have badly broken seds.  This is the case f.i. with Solaris, IRIX and
OSF/1.  It works fine for me with GNU sed version 2.05.

+ echo [Fwd: [Fwd: Re: [ace-users] misc.jet] (fwd) ] (fwd) 
+ sed -e s/^\(\(\[Fwd\|Re\):[         ]*\)*// -e s/\([        ]*\][   ]*\|[   
]*(fwd)[        ]*\)*$// 
[Fwd: [Fwd: Re: [ace-users] misc.jet] (fwd) ] (fwd)

Note, the output on the last line is absolutely the same as input.

    I get the output

        [ace-users] misc.jet

with GNU sed.  Can somebody else please confirm this?  It also seems to
work with your other examples, and the logic of the command seems ok
too.  Please note that the brackets "[ ]" contain a space and a tab, and
that you actually need the single quotes around the sed commands.

    Regards,

    Liviu Daia

-- 
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

<Prev in Thread] Current Thread [Next in Thread>