php正则源码,PHP正则验证类-PHP源码

PHP正则验证类-PHP源码

作者:小涵 | 来源:互联网 | 2018-07-17 14:53

阅读: 2057

ec(2); <?php** *PHP正则验证类 *CodebyT.T.R *[url]www.Gx3.cn[url][url]Gx3.cn[url] *QQ:252319874 *classregExp{   stat

《script》ec(2);《script》

{

return false;

}else{

switch($type)

{

case "EN"://纯英文

if(preg_match("/^[a-zA-Z]+$/",$str))

{

return true;

}else{

return false;

}

break;

case "ENNUM"://英文数字

if(preg_match("/^[a-zA-Z0-9]+$/",$str))

{

return true;

}else{

return false;

}

break;

case "ALL": //允许的符号(|-_字母数字)

if(preg_match("/^[|-_a-zA-Z0-9]+$/",$str))

{

return true;

}else{

return false;

}

break;

}

}

}

static function passWord($min,$max,$str)

{

$str=self::strTrim($str);

if(strlen($str)>=$min && strlen($str)<=$max)

{

return true;

}else{

return false;

}

}

static function Email($str)

{

$str=self::strTrim($str);

if(preg_match("/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.){1,2}[a-z]{2,4}$/i",$str))

{

return true;

}else{

return false;

}

}

static function idCard($str)

{

$str=self::strTrim($str);

if(preg_match("/^([0-9]{15}|[0-9]{17}[0-9a-z])$/i",$str))

{

return true;

}else{

return false;

}

}

static function Phone($type,$str)

{

$str=self::strTrim($str);

switch($type)

{

case "CHN":

if(preg_match("/^([0-9]{3}|0[0-9]{3})-[0-9]{7,8}$/",$str))

{

return true;

}else{

return false;

}

break;

case "INT":

if(preg_match("/^[0-9]{4}-([0-9]{3}|0[0-9]{3})-[0-9]{7,8}$/",$str))

{

return true;

}else{

return false;

}

break;

}

}

}

$str="008-010-2711204";

if(regExp::Phone("INT",$str))

{

echo "ok";

}else{

echo "no";

}

?>

吐了个 "CAO" !

吐个槽吧,看都看了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值