从文本文件中提取电子邮件地址

I am fetching the file content like

$text = file_get_contents(' MY PAGE URL HERE ');

I want to extract the mail addresses in the page. I am using the below code spinet.

$res = preg_match_all("/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i",$text,$matches);

Normally it is working fine. but getting an issue. If the page contain a mail id like suren.roy@gmail.com then it is extracting only roy@gmail.com. The text before the first . is eliminated.

you can try this :

preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/si',$text, $matches);