几个常见正则
2016-07-26 22:15
169 查看
正则语法:(30分钟入门教程)
http://deerchao.net/tutorials/regex/regex-1.htm
1、匹配外层中括号
(?i)(?<=\[)(.*)(?=\])
参照:(http://bbs.csdn.net/topics/380239087)
(http://book.51cto.com/art/200801/64658.htm)
2、匹配手机和身份证
Regex rgPhpone = new Regex(@"[1][3,4,5,8]\d{9}", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex rgID = new Regex(@"\d{17}[a-zA-Z]|\d{18}|\d{15}");
或者:
身份证:^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d|x|X){4})$
手机:^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$
http://deerchao.net/tutorials/regex/regex-1.htm
1、匹配外层中括号
(?i)(?<=\[)(.*)(?=\])
参照:(http://bbs.csdn.net/topics/380239087)
(http://book.51cto.com/art/200801/64658.htm)
2、匹配手机和身份证
Regex rgPhpone = new Regex(@"[1][3,4,5,8]\d{9}", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex rgID = new Regex(@"\d{17}[a-zA-Z]|\d{18}|\d{15}");
或者:
身份证:^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d|x|X){4})$
手机:^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$
相关文章推荐
- 编程中的抽象
- 简单缓冲区溢出逆向分析笔记
- Lightoj1265 Island of Survival 概率题
- 从苏宁电器到卡巴斯基第19篇:曲折考研路(下)
- http://blog.sina.com.cn/s/blog_5f103c9c0101atny.html
- 51nod 子序列的个数(动态规划)
- Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享
- shiro令牌环
- Apache 服务器下载、安装、应用
- linux携带密码登录其他远程机
- Java 反射
- HDU 5762 Teacher Bo (暴力)
- 数据结构学习笔记之用Java实现双向链表
- [PointCloud] GICP
- hdu1527 取石子游戏 【威佐夫博弈】
- 如何使用Gson工具类,以及使用listview加载相应的解析项
- c# datetimepicker中format设置
- 77.You executed the following command to perform a backup of the USERS tablespace: SQL> ALTER TABLES
- java设计模式_装饰模式
- 用c++实现红黑树的判断、插入、遍历操作