dqf60304 2015-08-31 10:52
浏览 153

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

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.

  • 写回答

1条回答 默认 最新

  • du9843 2015-08-31 10:59
    关注

    you can try this :

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

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元