Java examples for java.util.regex:Match Phone Number
Is a Mobile phone number by Regex
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static final String MOBILE = "^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\\d{8}$"; public static boolean isMobile(String str) { if (str.length() > 11) { return false; } else {/* w w w . j a v a 2 s. co m*/ return Regular(str, MOBILE); } } private static boolean Regular(String str, String pattern) { if (null == str || str.trim().length() <= 0) return false; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); return m.matches(); } }