脚本宝典收集整理的这篇文章主要介绍了php正则表达式编号和仅标志,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
例:
632444747将返回true
632444747将返回true
632444747将返回false
& 632444747将返回false
如何使用正则表达式实现这一目标?
谢谢.
PReg_match('/^\+?\d+$/',$str);
测试它
$strs = array('+632444747','632444747','632444747+','&632444747'); foreach ($strs as $str) { if (preg_match('/^\+?\d+$/',$str)) { print "$str is a phone number\n"; } else { print "$str is not a phone number\n"; } }
产量
+632444747 is a phone number 632444747 is a phone number 632444747+ is not a phone number &632444747 is not a phone number
以上是脚本宝典为你收集整理的php正则表达式编号和仅标志全部内容,希望文章能够帮你解决php正则表达式编号和仅标志所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。