Way back on Sun, May 30, 2004 at 2:47:01AM -0700, Sean wrote:
The following sed command was executed at the shell (escaping as
per the shell I happen to use), with the address string being piped
at it:
echo "(Sally) <sally(_at_)host(_dot_)example(_dot_)com>, \"Joe Bob\"
<joebob(_at_)host(_dot_)example(_dot_)com>, nobody(_at_)example(_dot_)com
\"nobody\", dick
<dick(_at_)example(_dot_)com>, <weed(_at_)example(_dot_)com> dick weed,
<doofus(_at_)example(_dot_)com>
doofus" | sed -e "s/\"[^\"]*\"\s*//g" -e
's/\(^\|,\)\([^,]\)*<\([^<>]*\)>\([^,]\)*/\1\3/g' -e 's/([^\(\)]*)//g' -e
"s/<\([^<>]*\)>/\1/g" -e "s/[ ]//g"
A belated thank you VERY much to Sean and Don for the regex thoughts.
By adding a space between the \1 and \3 substitution, and losing the
final space stripper, The regex above catches all the pathological
cases I have to deal with, so I can leave further refinements to
another day.
* the book:
_Mastering Regular Expressions_, by Jeffrey E. F. Friedl
(Sebastopol, Calif: O'Reilly and Associates, 1997)
ISBN 1-56592-257-3
http://www.oreilly.com/catalog/regex/
It's a must-have for the serious unix user. Grep, perl, sed, awk,
procmail, php -- so many tools have regexp support.
I will add it to my library. Thanks again! I think my tab must now
be up to a case of Blackwatch... :) Since I'm sure you'll want the
aged variety, I'll let you know when it's in!
Cheers,
Jim
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail