一个好用的正则匹配电话号手机号邮箱网址的方


$str = "<a href='https://www.baidu.com' target='_blank'>百度</a><a href='https://www.sina.com' target='_blank'>新浪</a>kod";

preg_match_all("/<a href=https://www.jb51.net/article/([\"\'])(http:\/\/([\w\d\.])+)[^>]*>(.*?)<\/a>/i", $str, $matches);

echo "<pre>";
var_dump($matches[2]);
echo "<br />";
var_dump($matches[4]);


匹配邮箱

复制代码 代码如下:


$emails = "wangzhanu@126.comha12wangzhanu@163.com";

preg_match_all("/([a-z0-9_\-\.]+)@(([a-z0-9]+[_\-]?)\.)+[a-z]{2,3}/i", $emails, $matches);

var_dump($matches[0]);


匹配手机以及电话号码

复制代码 代码如下:


$tel = "13911112222sf010-44444442dfg18811112222";

preg_match_all("/1[3,5,8]{1}[0-9]{1}[0-9]{8}|0[0-9]{2,3}-[0-9]{7,8}(-[0-9]{1,4})?/", $tel, $matches);

var_dump($matches);

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfywww.html