Java实现手机号的匹配验证

通过正则匹配实现手机号的验证:

 1 package demo;
 2 
 3 import java.util.regex.Matcher;
 4 import java.util.regex.Pattern;
 5 
 6 public class PhoneValidate {
 7 
 8     public static void main(String[] args) {
 9         String value="17518900000";
10         Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
11         Matcher m = p.matcher(value);
12         System.out.println(m.matches());//boolean
13     }
14 }

 

posted @ 2016-02-03 11:44  爱茹一婉年  阅读(1815)  评论(0编辑  收藏  举报