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