preg_match("/To: ([^<]+)<?([^>]+)?>?/i",$string,$matches);
returns email in $matches[1] in the first instance and name in $matches[1] and email in $matches[2] in the second. -----Original Message----- From: Robert Kornfeld [mailto:[EMAIL PROTECTED] Sent: 07 April 2004 09:32 To: [EMAIL PROTECTED] Subject: [PHP] regular expression hey, professionals out there: i need to write a parser for an email-header to retrieve the email of the 'To:'-field. there are 2 possibilities: 'To: [EMAIL PROTECTED]' or 'To: first foo <[EMAIL PROTECTED]>' i would only need the email-adress! does anyone know the regular expression that can handle both possibilities? (i give up!) thanx! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Legal Disclaimer:- Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this e-mail may be monitored by the Barclays Group for operational or business reasons. Barclays Bank PLC trading as "Shopsmart from Barclaycard". Registered Office: 54 Lombard Street London EC3P 3AH Registered in England, Registration No. 1026167. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php