Last active
August 29, 2015 14:17
-
-
Save xiekw2010/321f5370e49521fec113 to your computer and use it in GitHub Desktop.
常用正则
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
正则入门:http://deerchao.net/tutorials/regex/regex.htm | |
正则验证:http://tool.oschina.net/regex?optionGlobl=global# | |
======================= | |
常规 | |
======================= | |
+ 验证邮箱 | |
^\w+(\.\w+)*@[a-zA-Z0-9-]{2,}\.[a-zA-Z]{2,} | |
+ 中文字符(只是针对单个的) | |
[\u4e00-\u9fa5] | |
+ QQ号码 | |
[1-9][0-9]{4,} | |
+ 生份证号码 | |
^[1-9]\d{2}\d{3}(1|2)(9|0)([5-9]|0)\d\d[1-9]\d[1-9]\d{3}(\d|X)$ | |
+ 浮点数 | |
^-?(([1-9]\d*\.\d*)|(0\.\d*))$ | |
+ 邮编 | |
[1-9]\d{5}(?!\d) | |
======================= | |
断言 | |
======================= | |
+ 以ing结尾的单词 | |
/b\w+(?=ing/b) 比如sleeping 匹配出sleep | |
+ 以re开头的单词 repick 匹配出pick | |
(?<=/bre)/w+/b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment