电话号码验证

Posted 丶疏影横斜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了电话号码验证相关的知识,希望对你有一定的参考价值。

/**
* 验证电话号码
* 
* @param 待验证的字符串
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean IsTelephone(String str) {
String regex = "^(\\d{3,4}-)?\\d{6,8}$";
return match(regex, str);
}

 

以上是关于电话号码验证的主要内容,如果未能解决你的问题,请参考以下文章