diff --git a/src/main/java/xyz/zhouxy/plusone/commons/constant/PatternConsts.java b/src/main/java/xyz/zhouxy/plusone/commons/constant/PatternConsts.java
index 6bb7048..ad5b555 100644
--- a/src/main/java/xyz/zhouxy/plusone/commons/constant/PatternConsts.java
+++ b/src/main/java/xyz/zhouxy/plusone/commons/constant/PatternConsts.java
@@ -22,27 +22,39 @@ import java.util.regex.Pattern;
* 正则表达式常量
*
* @author ZhouXY
+ * @see RegexConsts
+ * @see xyz.zhouxy.plusone.commons.util.RegexTools
*/
public final class PatternConsts {
- // TODO 【添加】 新增身份证等正则常量
-
+ /** yyyyMMdd */
public static final Pattern BASIC_ISO_DATE = Pattern.compile(RegexConsts.BASIC_ISO_DATE);
+ /** yyyy-MM-dd */
public static final Pattern ISO_LOCAL_DATE = Pattern.compile(RegexConsts.ISO_LOCAL_DATE);
+ /** 密码 */
public static final Pattern PASSWORD = Pattern.compile(RegexConsts.PASSWORD);
+ /** 验证码 */
public static final Pattern CAPTCHA = Pattern.compile(RegexConsts.CAPTCHA);
+ /** 邮箱地址 */
public static final Pattern EMAIL = Pattern.compile(RegexConsts.EMAIL);
+ /** 中国大陆手机号 */
public static final Pattern MOBILE_PHONE = Pattern.compile(RegexConsts.MOBILE_PHONE);
+ /** 用户名 */
public static final Pattern USERNAME = Pattern.compile(RegexConsts.USERNAME);
+ /** 昵称 */
public static final Pattern NICKNAME = Pattern.compile(RegexConsts.NICKNAME);
+ /** 中国第二代居民身份证 */
+ public static final Pattern CHINESE_2ND_ID_CARD_NUMBER
+ = Pattern.compile(RegexConsts.CHINESE_2ND_ID_CARD_NUMBER);
+
private PatternConsts() {
throw new IllegalStateException("Utility class");
}
diff --git a/src/main/java/xyz/zhouxy/plusone/commons/constant/RegexConsts.java b/src/main/java/xyz/zhouxy/plusone/commons/constant/RegexConsts.java
index aa2ca36..f1bad7f 100644
--- a/src/main/java/xyz/zhouxy/plusone/commons/constant/RegexConsts.java
+++ b/src/main/java/xyz/zhouxy/plusone/commons/constant/RegexConsts.java
@@ -20,28 +20,30 @@ package xyz.zhouxy.plusone.commons.constant;
* 正则表达式常量
*
* @author ZhouXY
+ * @see PatternConsts
*/
public final class RegexConsts {
- // TODO 【优化】 根据需要添加 group
-
- // TODO 【添加】 新增身份证等正则常量
-
public static final String BASIC_ISO_DATE = "^(?\\d{4})(?\\d{2})(?\\d{2})";
public static final String ISO_LOCAL_DATE = "^(?\\d{4})-(?\\d{2})-(?\\d{2})";
public static final String PASSWORD = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[\\w\\\\!#$%&'*\\+\\-/=?^`{|}~@\\(\\)\\[\\]\",\\.;':><]{8,32}$";
- public static final String CAPTCHA = "^[0-9A-Za-z]{4,6}$";
+ public static final String CAPTCHA = "^\\w{4,6}$";
- public static final String EMAIL = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
+ public static final String EMAIL
+ = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")"
+ + "@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
public static final String MOBILE_PHONE = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$";
- public static final String USERNAME = "^[\\da-zA-Z_.@\\\\]{4,36}$";
+ public static final String USERNAME = "^[\\w_.@\\\\]{4,36}$";
- public static final String NICKNAME = "^[\\da-zA-Z_.@\\\\]{4,36}$";
+ public static final String NICKNAME = "^[\\w_.@\\\\]{4,36}$";
+
+ public static final String CHINESE_2ND_ID_CARD_NUMBER
+ = "^(?(?(?\\d{2})\\d{2})\\d{2})(?\\d{8})\\d{2}(?\\d)([\\dXx])$";
private RegexConsts() {
throw new IllegalStateException("Utility class");