I'm using this code to parse out emails from a string:
function get_emails ($str) {
$pattern = '/([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' .
'(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)/i';
preg_match ($pattern, $str, $matches);
return $matches;
}
It works well except when the address has more than one period in domain. So [email protected] works fine but [email protected] get's cut at [email protected]
What can I change to fix this?
Thanks!