日期:2014-05-17  浏览次数:20598 次

正则的问题,截取下面文章里的邮箱和Registrant:后的姓名,但是有好多不同情况,请问正则表达式该怎么写?
情况1:
Registrant:
   
  jin mi
   
  jin mi 8
   
  shen zhen, guang dong 518000
   
  China
   
   
  Registered through: GoDaddy.com, LLC (http://www.godaddy.com)
   
  Domain Name: 760PK.COM
   
  Created on: 04-May-12
   
  Expires on: 04-May-13
   
  Last Updated on: 28-Jun-12
   
   
  Administrative Contact:
   
  mi, jin linliangemail@qq.com
   
  jin mi 8
   
  shen zhen, guang dong 518000
   
  China
   
  +86.13510187966
   
   
  Technical Contact:
   
  mi, jin linliangemail@qq.com
   
  jin mi 8
   
  shen zhen, guang dong 518000
   
  China
   
  +86.13510187966  
情况2:
Registrant:
   
  Domain Administrator
   
  Netease.com, Inc
   
  No.16, Ke Yun Rd Tianhe District
   
  GuangZhou GuangDong 510665
   
  CN
   
  nsadmin@corp.netease.com +86.2085106370 Fax: +86.2085106370
   
   
情况3:
Registrant:
   
  Zhiyong Duan
   
  Beijing Baidu Netcom Science Technology Co., Ltd.
   
  3F Baidu Campus No.10 Shangdi 10th Street Haidian District
   
  Beijing Beijing 100085
   
  CN
   
  domainmaster@baidu.com +86.1059924216 Fax: +86.1059927435
   
   


------解决方案--------------------
PHP code

//姓名
preg_match_all('/Registrant:\s*(\w+\s+\w+)/s',$str,$name); 
print_r($name[1]);
//邮箱
preg_match_all('/\b[\w_]+@[\w\._]+/m',$str,$email); 
print_r($email);