From: Francis Galiegue Date: Sat, 01 Nov 2008 19:56:37 GMT Subject: Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used. Message-ID: <200811012056.37220.fg@one2team.net> In-Reply-To: <20081101174352.GG26229@artemis.corp> Le Saturday 01 November 2008 18:43:52 Pierre Habouzit, vous avez écrit : [...] > Your regex fails to parse: > > "Someone with a comma, and an escape double quote \" in its name" Easy fix: replace "[^"]+" with "[^"]+(?:\\"[^"]*)*". > Oh yes. Regexes _are_ the way to do serious parsing. All MIME packages you will find floating around use regexes to parse mail headers correctly. Granted, adhering to the RFC822 to the letter is rather hard. But I have a sample program here that can not only parse the escaped double quote, but also take account for the multiple line stuff and multiple headers of the same type where email addresse are valid (To:, Cc:, Bcc:). See attachment. Feel free to use the code. ---- fg@erwin ~ $ cat t.txt To: John Doe , Random Joe , Superman , "Someone with a comma, inside its tag name" To: bbr@one2team.com, u1@whatever.org, u2@wherever.ru, u3@blah.com fg@erwin ~ $ perl t.pl Found mail: Random Joe Found mail: Superman Found mail: "Someone with a comma, inside its tag name" Found mail: bbr@one2team.com Found mail: u1@whatever.org Found mail: u2@wherever.ru Found mail: u3@blah.com ---- -- fge