java针对电话号码正则匹配实例
作者:懒萝卜 时间:2023-07-15 05:49:32
本文实例讲述了java针对电话号码正则匹配的方法。分享给大家供大家参考。具体如下:
public interface RegExpConst {
/**
* 手机号码
* 移动:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
* 联通:130,131,132,152,155,156,185,186
* 电信:133,1349,153,180,189
*/
String MOBILE = "^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
/**
* 中国移动:China Mobile
* 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
*/
String CM = "^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
/**
* 中国联通:China Unicom
* 130,131,132,152,155,156,185,186
*/
String CU = "^1(3[0-2]|5[256]|8[56])\\d{8}$";
/**
* 中国电信:China Telecom
* 133,1349,153,180,189
*/
String CT = "^1((33|53|8[09])[0-9]|349)\\d{7}$";
/**
* 大陆地区固话及小灵通
* 区号:010,020,021,022,023,024,025,027,028,029
* 号码:七位或八位
*/
String PHS = "^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
}
PS:这里再为大家提供2款非常方便的正则表达式工具供大家参考使用:
JavaScript正则表达式在线测试工具:
http://tools.jb51.net/regex/javascript
正则表达式在线生成工具:
http://tools.jb51.net/regex/create_reg
希望本文所述对大家的java程序设计有所帮助。
标签:java,正则
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java实战之用springboot+netty实现简单的一对一聊天
2023-12-03 07:28:19
![](https://img.aspxhome.com/file/2023/0/61080_0s.png)
详解spring boot实现多数据源代码实战
2022-05-01 20:18:36
详解Android短信的发送和广播接收实现短信的监听
2022-08-14 16:55:23
微信公众号开发之回复图文消息java代码
2022-11-24 00:56:19
![](https://img.aspxhome.com/file/2023/1/86701_0s.jpg)
java锁synchronized面试常问总结
2023-08-01 05:11:37
![](https://img.aspxhome.com/file/2023/7/57917_0s.png)
Java图形用户界面设计(Swing)的介绍
2022-08-23 03:29:37
![](https://img.aspxhome.com/file/2023/4/75654_0s.jpg)
一文带你了解C#中的协变与逆变
2022-08-06 22:31:21
基于Spring Boot应用ApplicationEvent案例场景
2023-08-17 22:38:12
![](https://img.aspxhome.com/file/2023/0/96120_0s.png)
Java中的vector类使用示例小结
2023-09-01 02:46:59
Android调用系统图库获取图片的方法
2023-09-23 04:13:02
![](https://img.aspxhome.com/file/2023/8/139628_0s.jpg)
Android中Intent传递对象的两种方法Serializable,Parcelable
2021-05-24 03:11:58
AsyncTask官方文档教程整理
2023-07-31 20:25:08
基于android实现五子棋开发
2022-05-22 14:21:43
![](https://img.aspxhome.com/file/2023/3/126683_0s.jpg)
MyBatis执行动态SQL的方法
2021-05-29 04:02:17
Android Studio实现简易进制转换计算器
2023-09-17 04:19:29
Java泛型的类型擦除示例详解
2023-07-02 13:38:17
![](https://img.aspxhome.com/file/2023/0/78330_0s.png)
Android实现悬浮窗效果
2022-08-17 05:59:40
java图片添加水印实例代码分享
2022-06-10 04:06:03
Android监听Home键和Back键的区别介绍
2022-09-11 11:21:03
一文带你弄懂Java中线程池的原理
2023-09-10 20:59:02
![](https://img.aspxhome.com/file/2023/5/90025_0s.png)