forked from plusone/plusone-commons
新增中国二代居民身份证正则常量
parent
c06c486ab9
commit
2e4e32af45
|
@ -22,27 +22,39 @@ import java.util.regex.Pattern;
|
|||
* 正则表达式常量
|
||||
*
|
||||
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
|
||||
* @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");
|
||||
}
|
||||
|
|
|
@ -20,28 +20,30 @@ package xyz.zhouxy.plusone.commons.constant;
|
|||
* 正则表达式常量
|
||||
*
|
||||
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
|
||||
* @see PatternConsts
|
||||
*/
|
||||
public final class RegexConsts {
|
||||
|
||||
// TODO 【优化】 根据需要添加 group
|
||||
|
||||
// TODO 【添加】 新增身份证等正则常量
|
||||
|
||||
public static final String BASIC_ISO_DATE = "^(?<y>\\d{4})(?<M>\\d{2})(?<d>\\d{2})";
|
||||
|
||||
public static final String ISO_LOCAL_DATE = "^(?<y>\\d{4})-(?<M>\\d{2})-(?<d>\\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
|
||||
= "^(?<county>(?<city>(?<province>\\d{2})\\d{2})\\d{2})(?<birthDate>\\d{8})\\d{2}(?<gender>\\d)([\\dXx])$";
|
||||
|
||||
private RegexConsts() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
|
|
Loading…
Reference in New Issue