For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2006 > regex help needed to parse email









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author regex help needed to parse email
tgh003@gmail.com

2006-07-20, 9:56 pm

How do i get the email address from the line below using a regex using
eregi_replace or something similar in php?

"Name" <user@example.com>

Thanks.

Rik

2006-07-21, 7:56 am

tgh003@gmail.com wrote:
> How do i get the email address from the line below using a regex using
> eregi_replace or something similar in php?
>
> "Name" <user@example.com>


With very simple validating (only checking for something@something):

if(preg_match('/<([^>@]+@[^>@]+)>/',$string,$matches)){
$email = $matches[1];
}

Grtz,
--
Rik Wasmus


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com