Here you can find the source of isPhoneNumber(final String phone)
public static boolean isPhoneNumber(final String phone)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String telNumRegex = "((\\d{11})|^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)"; public static boolean isPhoneNumber(final String phone) { Pattern pattern = Pattern.compile(telNumRegex); Matcher macther = pattern.matcher(phone.trim()); return macther.find() ? true : false; }/* w w w . jav a 2s . c o m*/ }