教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 只包括数字正则表达试

只包括数字正则表达试

发布时间:2016-10-26   编辑:jiaochengji.com
教程集为您提供只包括数字正则表达试等资源,欢迎您收藏本站,我们将为您提供最新的只包括数字正则表达试资源

/

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy8955')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy8955> function funcnum($str,$num1='',$num2='')//数字正则表达试
 {
  if($num1!='' and $num2!=''){
   return (preg_match("/^[0-9]{".$num1.",".$num2."}$/",$str))?true:false;
  }else{
   return (preg_match("/^[0-9]/",$str))?true:false;
  }
 }

/*
一般情况下,要只限制全数字,大多用到正则解决是最方法的了。

您可能感兴趣的文章:

[关闭]
~ ~