Here you can find the source of isPhone(String phoneNumber)
public static boolean isPhone(String phoneNumber)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isPhone(String phoneNumber) { String strPattern = "([0-9]{3,4}-)?[0-9]{4,12}"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(phoneNumber); return m.matches(); }/*from w ww.j av a 2 s. c om*/ }