procmail
[Top] [All Lists]

Re: String Manipulation

1999-04-09 15:58:41
At 02:49 PM 4/9/99 -0400, Randy James wrote:
I am a little new to procmail...

I am trying to take only the email address part out of the..
From:   line.
I figured out how to use
* MYFROM ?? ()\/<.*
to get the entire from line after ther first < sign, but this also includes
the < sign and the > sign along with the trailing end of line character.

does anyone know how to chop off the < and > so I can just get
someone(_at_)somewhere(_dot_)com?

* MYFROM ?? ()<\/[^>]+

where:
    ()     probably not needed now, but what the heck, it's safe
    <      a literal match
    \/     starts filling $MATCH after the "<"
    [^>]+  one or more characters not a ">"

Matching will be up to, but not including, the ">".

This can still be fooled by things like:
  "I am the <greatest>" <somehacker(_at_)domain(_dot_)com> (just making "<life> 
difficult")
so if you really care, you need to use formail or something to chop off the
garbage.  Parsing arbitrary legal addresses with procmail alone just isn't
possible, but the $MATCH will probably handle anyone you know :-)

Hope that helps,
Stan

<Prev in Thread] Current Thread [Next in Thread>
  • Re: String Manipulation, Stan Ryckman <=