`

android 手机号码正则表达式写法

 
阅读更多

文章转自:http://ipc.javaeye.com/blog/689257

要更加准确的匹配手机号码只匹配11位数字是不够的,比如说就没有以144开始的号码段,

故先要整清楚现在已经开放了多少个号码段,国家号码段分配如下:

移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188

联通:130、131、132、152、155、156、185、186

电信:133、153、180、189、(1349卫通)

详见:[url=http://blog.myspace.cn/e/405268924.htm]http://blog.myspace.cn/e/405268924.htm[/url] 那么现在就可以正则匹配测试了,

Java代码
  1. importjava.io.IOException;
  2. importjava.util.regex.Matcher;
  3. importjava.util.regex.Pattern;
  4. publicclassClassPathResource{
  5. publicstaticbooleanisMobileNO(Stringmobiles){
  6. Patternp=Pattern.compile("^((13[0-9])|(15[^4,//D])|(18[0,5-9]))//d{8}$");
  7. Matcherm=p.matcher(mobiles);
  8. System.out.println(m.matches()+"---");
  9. returnm.matches();
  10. }
  11. publicstaticvoidmain(String[]args)throwsIOException{
  12. System.out.println(ClassPathResource.isMobileNO("18616155153"));
  13. }
  14. }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics