Java Regular Expression match mobile phone number in China

Description

Java Regular Expression match mobile phone number in China


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] argv) throws Exception {
        String mobiles = "";
        System.out.println(isMobile(mobiles));
    }//from  w  w  w .  ja v a 2  s  .  c  om

    public static boolean isMobile(String mobiles) {
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }
}



PreviousNext

Related