php 汉字字母数字下划线正则表达式

匹配首尾空白字符的正则表达式:^s*|s*$ 评注:可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式.

匹配首尾空白字符的正则表达式:^s*|s*$

  1. $action = trim($_get['action']); 
  2. if($action == "sub"
  3.     $str = $_post['dir'];     
  4.     //if(!preg_match("/^[".chr(0xa1)."-".chr(0xff)."a-za-z0-9_]+$/",$str)) //gb2312汉字字母数字下划线正则表达式  
  5.     if(!preg_match("/^[x{4e00}-x{9fa5}a-za-z0-9_]+$/u",$str))   //utf-8汉字字母数字下划线正则表达式 
  6.     {    
  7.         echo "<font color=red>您输入的[".$str."]含有违法字符</font>";    
  8.     } 
  9.     else  
  10.     { 
  11.         echo "<font color=green>您输入的[".$str."]完全合法,通过!</font>";    
  12.     } 
  13. ?> 
  14. <form method="post" action=""
  15. 输入字符(数字,字母,汉字,下划线): 
  16.     <input type="text" name="dir" value=""
  17.     <input type="submit" value="提交"
  18. </form> 

匹配网址url的正则表达式:[a-za-z]+://[^s]* 

评注:网上流传的版本功能很有限,上面这个基本可以满足需求 

匹配帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):^[a-za-z][a-za-z0-9_]{4,15}$ 

评注:表单验证时很实用 

匹配国内电话号码:d{3}-d{8}|d{4}-d{7} 

评注:匹配形式如 0511-4405222 或 021-87888822 

匹配腾讯qq号:[1-9][0-9]{4,} 

评注:腾讯qq号从10000开始 

匹配中国邮政编码:[1-9]d{5}(?!d) 

评注:中国邮政编码为6位数字 

匹配身份证:d{15}|d{18} 

评注:中国的身份证为15位或18位 

匹配ip地址:d+.d+.d+.d+ 

评注:提取ip地址时有用

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php 汉字字母数字下划线正则表达式

59 评论

  1. buy sildenafil 100mg online cheap careprost price robaxin 500mg drug

  2. isotretinoin 20mg over the counter buy amoxil 1000mg ivermectin australia

  3. ramipril order online ramipril cheap astelin 10 ml over the counter

  4. buy tadalafil 10mg online cheap cialis sale order symmetrel generic

  5. provigil 100mg generic order modafinil pill can you buy stromectol over the counter

  6. tadalafil 20mg canada clomipramine us buy anafranil 25mg online cheap

  7. zyloprim sale oral zetia ezetimibe 10mg drug

  8. buy retin cream sale buy tretinoin gel order avanafil 100mg online cheap

  9. buy lamisil 250mg without prescription lamisil sale amoxicillin cheap

  10. buy generic actos 30mg viagra pills generic viagra 50mg

  11. tadalafil 20mg brand trimox ca amoxicillin 500mg canada

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡