From c42df923db54cbbe8f37dde415c1d0b7450614a0 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期四, 09 五月 2024 10:04:16 +0800 Subject: [PATCH] 手机号校验优化 --- src/main/java/com/hx/util/RegValidatorUtil.java | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/hx/util/RegValidatorUtil.java b/src/main/java/com/hx/util/RegValidatorUtil.java index d3d68a2..ea51c5b 100644 --- a/src/main/java/com/hx/util/RegValidatorUtil.java +++ b/src/main/java/com/hx/util/RegValidatorUtil.java @@ -88,15 +88,15 @@ return match(regex, str); } - /** - * 楠岃瘉杈撳叆鎵嬫満鍙风爜 - * - * @param str 寰呴獙璇佺殑瀛楃锟�? - * @return 濡傛灉鏄鍚堟牸寮忕殑瀛楃锟�?,杩斿洖 <b>true </b>,鍚﹀垯锟�? <b>false </b> - */ - public static boolean IsHandset(String str) { - String regex = "^[1]+[3,5]+\\d{9}$"; - return match(regex, str); + /**鏍¢獙鎵嬫満鍙风爜 + * @param phoneNumber 鎵嬫満鍙� + * @return 鏍¢獙缁撴灉 + */ + public static boolean IsHandset(String phoneNumber) { + if ((phoneNumber != null) && (!phoneNumber.isEmpty())) { + return Pattern.matches("^1[3-9]\\d{9}$", phoneNumber); + } + return false; } /** -- Gitblit v1.8.0