Home  >  Article  >  php教程  >  电话号码正则表达式

电话号码正则表达式

WBOY
WBOYOriginal
2016-06-08 17:26:161034browse

下面提供了二种电话号码正则表达式一种是js电话号验证与一款是php验证电话号的正则表达式实例。

<script>ec(2);</script>
 代码如下 复制代码
function funcphone($str)//电话号码正则表达式
{
 return (preg_match("/^(((d{3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,8}$/",$str))?true:false;

//js 电话号码正则表达式

 代码如下 复制代码
regexps教程.isphone = /^(((d{2,3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,7}(-d{1,4})?$/;
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