mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-16 04:59:35 +08:00
增加澳门和台湾手机号格式校检
This commit is contained in:
parent
4f634c384d
commit
f3f7653b78
@ -63,10 +63,22 @@ public class PatternPool {
|
|||||||
* eg: 中国大陆: +86 180 4953 1399,2位区域码标示+13位数字
|
* eg: 中国大陆: +86 180 4953 1399,2位区域码标示+13位数字
|
||||||
* 中国大陆 +86 Mainland China
|
* 中国大陆 +86 Mainland China
|
||||||
* 中国香港 +852 Hong Kong
|
* 中国香港 +852 Hong Kong
|
||||||
* 中国澳门 +853 Macau
|
* 中国澳门 +853 Macao
|
||||||
* 中国台湾 +886 Taiwan
|
* 中国台湾 +886 Taiwan
|
||||||
*/
|
*/
|
||||||
public final static Pattern MOBILE_HK = Pattern.compile("(?:0|852|\\+852)?\\d{8}");
|
public final static Pattern MOBILE_HK = Pattern.compile("(?:0|852|\\+852)?\\d{8}");
|
||||||
|
/**
|
||||||
|
* 中国台湾移动电话
|
||||||
|
* eg: 中国台湾: +886 09 60 000000, 三位区域码+号码以数字09开头 + 8位数字, 中国台湾手机号码10位数
|
||||||
|
* 中国台湾 +886 Taiwan 国际域名缩写:TW
|
||||||
|
*/
|
||||||
|
public final static Pattern MOBILE_TW = Pattern.compile("(?:0|886|\\+886)?(?:|-)09\\d{8}");
|
||||||
|
/**
|
||||||
|
* 中国澳门移动电话
|
||||||
|
* eg: 中国台湾: +853 68 00000, 三位区域码 +号码以数字6开头 + 7位数字, 中国台湾手机号码8位数
|
||||||
|
* 中国澳门 +853 Macao 国际域名缩写:MO
|
||||||
|
*/
|
||||||
|
public final static Pattern MOBILE_MO = Pattern.compile("(?:0|853|\\+853)?(?:|-)6\\d{7}");
|
||||||
/**
|
/**
|
||||||
* 座机号码
|
* 座机号码
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,28 @@ public class PhoneUtil {
|
|||||||
return Validator.isMatchRegex(PatternPool.MOBILE_HK, value);
|
return Validator.isMatchRegex(PatternPool.MOBILE_HK, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证是否为手机号码(台湾)
|
||||||
|
* @param value 手机号码
|
||||||
|
* @return 是否为台湾手机号码
|
||||||
|
* @since 5.6.6
|
||||||
|
* @author ihao
|
||||||
|
*/
|
||||||
|
public static boolean isMobileTw(CharSequence value) {
|
||||||
|
return Validator.isMatchRegex(PatternPool.MOBILE_TW, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证是否为手机号码(澳门)
|
||||||
|
* @param value 手机号码
|
||||||
|
* @return 是否为澳门手机号码
|
||||||
|
* @since 5.6.6
|
||||||
|
* @author ihao
|
||||||
|
*/
|
||||||
|
public static boolean isMobileMo(CharSequence value) {
|
||||||
|
return Validator.isMatchRegex(PatternPool.MOBILE_MO, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证是否为座机号码(中国)
|
* 验证是否为座机号码(中国)
|
||||||
*
|
*
|
||||||
@ -66,11 +88,11 @@ public class PhoneUtil {
|
|||||||
* 验证是否为座机号码+手机号码(CharUtil中国)+ 400 + 800电话 + 手机号号码(香港)
|
* 验证是否为座机号码+手机号码(CharUtil中国)+ 400 + 800电话 + 手机号号码(香港)
|
||||||
*
|
*
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @return 是否为座机号码+手机号码(中国)+手机号码(香港)
|
* @return 是否为座机号码+手机号码(中国)+手机号码(香港)+手机号码(台湾)+手机号码(澳门)
|
||||||
* @since 5.3.11
|
* @since 5.3.11
|
||||||
*/
|
*/
|
||||||
public static boolean isPhone(CharSequence value) {
|
public static boolean isPhone(CharSequence value) {
|
||||||
return isMobile(value) || isTel400800(value) || isMobileHk(value);
|
return isMobile(value) || isTel400800(value) || isMobileHk(value) || isMobileTw(value) || isMobileMo(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user