最新的java正则表达式判断手机号,支持虚拟运营商170号段

国家号码段分配如下:   

  • 移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188、182
  • 联通:130、131、132、152、155、156、185、186
  • 电信:133、153、180、189、177、(1349卫通)
  • 虚拟:170
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.IOException;  
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ClassPathResource {

  public static boolean isMobileNO(String mobiles) {
  Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(14[57])|(17[0])|(17[7])|(18[0,0-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
System.out.println(m.matches()+"---");
return m.matches();
  }

  public static void main(String[] args) throws IOException {

   System.out.println(ClassPathResource.isMobileNO("14738381438"));

  }
}

版权声明:本文为博主原创文章,未经博主允许不得转载。