Home  >  Article  >  Backend Development  >  求高难度正则解决方法

求高难度正则解决方法

WBOY
WBOYOriginal
2016-06-13 09:58:45964browse

求高难度正则
一段话,如:
@abc falieurisdlfalsjdfj Email: [email protected] alkjdiruasjdflasdfj @abc.uk salkdjfoawuierj @123,lskdufasjidfja

上面这段话中 [email protected] 和 @abc.uk [email protected] 而不要取出 [email protected] @abc.cn 就像微博中一样 @符号后面,逗号或者句号前面的内容取出来,[email protected]




------解决方案--------------------

PHP code
$s = <font color="#e78608">------解决方案--------------------</font><br>田心老师的没有考虑到  [email protected]<br>刚学习正则,来个。<br><br>
PHP code
<?php $str = "@abc falieurisdlfalsjdfj Email: [email&#160;protected] alkjdiruasjdflasdfj @abc.uk salkdjfoawuierj @123,lskdufasjidfja";preg_match_all("/(^|\s *)@([\w.]+)/is",$str,$arr);print_r($arr);<div class="clear">
                 
              
              
        
            
Statement:
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