Parsing the output of --list-keys

Werner Koch wk@gnupg.org
Tue, 18 Jan 2000 13:44:58 +0100


On Mon, 17 Jan 2000, Jonas Steverud wrote:


> <tnelson@conceptech.com>" is not hard since the number of characters
> from the left marging is 31 (i.e. (forward-char 31)). The problem is
> to get "Tony Nelson", "(optional comment)" and
> "tnelson@conceptech.com".
What you should do here is RFC822 address parsing. Doing it with r.e. is not trivial. However, if this user ID is GnuPG generated it is easy to get all three parts: 1. part: Collect everything up to (but excluding) the first opening parenthesis or the first left angle bracket. 2. part: Only if you stopped at a parenthesis, collect everthing up to the closing parenthesis. Although it is not yet allowed, you might want to keep a counter of opening closing parenthesis. 3. part: Only if you have a left angle bracket, collect everything up to the right angle bracket. It should be easy to construct a sed,awk,perl r.e. for this.
> I have found a way of doing this with regexps so the problem is
> solved, but if --with-colons had put colons between the wanted parts
No that is not possible. -- Werner Koch at guug.de www.gnupg.org keyid 621CC013 Boycott Amazon! - http://www.gnu.org/philosophy/amazon.html