com.zcj.util.UtilRegex Maven / Gradle / Ivy
package com.zcj.util;
import java.util.regex.Pattern;
/**
* 正则表达式
*
* @author [email protected]
* @since 2019/5/10
*/
public class UtilRegex {
// 单个数字字母下划线
public static final String REGEX_LNL_ONE = "[0-9A-Za-z_]";
// 单个中文
public static final String REGEX_CHINESE_ONE = "[\u4e00-\u9fa5]";
// 全数字
public static final String REGEX_NUMBER = "[0-9]+";
// 数值
public static final String REGEX_NUMERIC = "^(\\-|\\+)?\\d+(\\.\\d+)?$";
// 全中文
public static final String REGEX_CHINESE_ALL = "^[\u4e00-\u9fa5]+$";
// 手机号码
public static final String REGEX_PHONE = "^[1]{1}[0-9]{10}$";
// 中国移动手机号码
public static final String REGEX_PHONE_MOBILE = "^((13[4-9])|147|150|151|152|157|158|159|178|182|183|184|187|188)[0-9]{8}";
// 车牌号
public static final String REGEX_CAR_NUMBER = "^[\u4e00-\u9fa5]{1}[A-Za-z]{1}[A-Za-z_0-9]{5}$";
// 邮箱
public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
// MAC 地址(使用“:”和“-”分隔符)
public static final String REGEX_MAC_SEP = "^([0-9a-fA-F]{2})(([/\\s:-][0-9a-fA-F]{2}){5})$";
// MAC 地址(无分隔符)
public static final String REGEX_MAC_NO_SEP = "^([0-9a-fA-F]{2})(([0-9a-fA-F]{2}){5})$";
// IP地址
public static final String REGEX_IP = "\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b";
// src=***
public static final Pattern PATTERN_SRC = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)");
// <>
public static final Pattern PATTERN_HTML = Pattern.compile("<([^>]*)>");
// 下划线:_
public static final Pattern PATTERN_UNDERSCORE = Pattern.compile("_(\\w)");
}