Home > Backend Development > PHP Tutorial > 正则的有关问题,截取上面文章里的邮箱和Registrant:后的姓名,但是有好多不同情况,请教正则表达式该如何写

正则的有关问题,截取上面文章里的邮箱和Registrant:后的姓名,但是有好多不同情况,请教正则表达式该如何写

WBOY
Release: 2016-06-13 13:16:44
Original
876 people have browsed it

正则的问题,截取下面文章里的邮箱和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); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template