|
Posted by Steve on 10/22/07 16:53
"AnrDaemon" <anrdaemon@freemail.ru> wrote in message
news:1979714934.20071021180056@freemail.ru...
> Greetings, gezerpunta.
> In reply to Your message dated Thursday, October 18, 2007, 18:59:31,
>
> <?php
>
> $s = 'celo@tum.com, "mnp test" <celo@tum.com>,"test testt" <otur@par.com>,
> sett@tttt.com,test@twest.com';
>
> if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
> $s, $ta))
> {
> var_export($ta[1]);
> }
of course you would. however, notice that whatever your prowess at regex,
you lack understanding of the basic email conventions explained in the
rfc(s). your preg doesn't allow for atomic account names. ;^)
hmmmm...this *does* (and then some).
function isEmail($email)
{
if (!$email){ return false; }
$pattern =
"/^((\"[^\"]*?\")|([^\(\)\<\>\@\,\;\:\\\"\[\]\s\*\/]+))@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$/si";
return preg_match($pattern, $email);
}
the pattern above simply needs to be applied to the entire string, and you
get what you want.
[Back to original message]
|