Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkPhone(String phone) { Pattern p = Pattern.compile( "^(((13[0-9])|(14[5,7])|(17[0|5-8])|(15([0-3]|[5-9]))|(18([0-9])))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$"); Matcher m = p.matcher(phone); return m.matches(); } }