修改 email 的正则常量

1. fix: Email 的 Pattern 不区分大小写
2. docs: 标注正则表达式的出处
This commit is contained in:
zhouxy108 2025-03-22 17:45:02 +08:00
parent 26efd1125e
commit 29519f3489
2 changed files with 4 additions and 1 deletions

View File

@ -61,7 +61,7 @@ public final class PatternConsts {
*
* @see RegexConsts#EMAIL
*/
public static final Pattern EMAIL = Pattern.compile(RegexConsts.EMAIL);
public static final Pattern EMAIL = Pattern.compile(RegexConsts.EMAIL, Pattern.CASE_INSENSITIVE);
/**
* 中国大陆手机号

View File

@ -32,6 +32,9 @@ public final class RegexConsts {
public static final String CAPTCHA = "^\\w{4,6}$";
/**
* from https://emailregex.com/
*/
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])+)\\])";