Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isMobile(String num) { boolean isValid = false; String expre = "(^(13|15|18|14)[0-9]{9}$)"; // String expre = "^\\(?(\\d{3})\\)?[-]?(\\d{3})[-]?(\\d{5})$"; // CharSequence inputStr = num; Pattern pattern = Pattern.compile(expre); Matcher matcher = pattern.matcher(num); if (matcher.matches()) { isValid = true; } return isValid; } }