Mobile number segment static Pattern P1 = Pattern.compile ("^ (13[4-9) | ( 15[0-2,7-9]) | (18[2-4,7-8]|14[5,7]) |178) \\d{8}$ "); static Pattern P2 = Pattern.compile ("^ (1705) \\d{7}$"); Unicom number segment static Pattern p3 = Pattern.compile ("^ ((13[0-2)) | ( 15[5,6]) | (18[5,6]) |176) \\d{8}$ "); Static pattern P4 = Pattern.compile ("^ (1709) \\d{7}$");//signal segment static Pattern P5 = Pattern.compile ("^ (133|153| ( 18[0-1,9]) (|177) \\d{8}$ "); Static Pattern P6 = Pattern.compile ("^ (1700) \\d{7}$");//All number segment public static Pattern Allphonenumberpattern=pattern.compi Le ("[1] (3[0-9]|4[57]|5[012356789]|8[0-9]) [0-9]{8}"); public static Pattern Phonenumberfor170pattern=pattern.compile ("[1] (7[0][059]|7[678][0-9]) [0-9]{7}"); public static String Replaceallpattern = "([0-7]|[ 9]) ([0-5]|[ 7-9]) \\d{11,} "; public static Pattern Phonenumberforlinepattern=pattern.compile ("[1] (3[0-9]|4[57]|5[012356789]|8[0-9]) [0-9]{8}"); public static Pattern Phonenumberfor86linepattern=pattern.compile ("^\\+86[1" (3[0-9]|4[57]|5[012356789]|8[0-9]) [ 0-9]{8}$ "); public static Pattern Phonenumberfor170linepattern=pattern.compile ("[1] (7[0][059]|7[678][0-9]) [0-9]{7}"); public static Pattern Phonenumberfor86170linepattern=pattern.compile ("^\\+86[1" (7[0][059]|7[678][0-9)) [0-9]{7}$] ; /** * Method Description * Is the mobile number segment * 134, 135, 136, 137, 138, 139, 150, 151, 152, 157 (TD Exclusive), 158, 159;182, 183, 184, 187, 188, 1705, 145, 147 * @ param phone * @return */public static Boolean ismobile (String phone) {Matcher m1 = P1.matcher (phone); Matcher m2 = p2.matcher (phone), if (m1.matches () | | m2.matches ()) {return true;} return false; }/** * Method Description * is the unicom segment * 130, 131, 132, 155, 156, 185, 186, 1709 * @param phone * @return */public static Boolean istelecom (String Phone) {Matcher m1 = P3.matcher (phone); Matcher m2 = p4.matcher (phone), if (m1.matches () | | m2.matches ()) {return true;} return false; }/** * Method Description * is the signal segment * 133, 153, 180, 181, 189, 1700 * @param phone * @return */public static Boolean isunicom (String phone) {M Atcher m1 = P5.matcher (phone); Matcher m2 = p6.matcher (phone), if (M1.matches () || M2.matches ()) {return true;} return false; }public static void Main (string[] args) {System.out.println (istelecom ("13412345678")); System.out.println (istelecom ("13052345678")); System.out.println (istelecom ("18612345678")); System.out.println (istelecom ("18412345678")); System.out.println (isunicom ("13312345678")); System.out.println (isunicom ("13412345678")); System.out.println (isunicom ("18112345678")); System.out.println (isunicom ("18912345678"));
Mobile phone number Help class