前端之家收集整理的这篇文章主要介绍了
常用正则表达式使用,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public static final String VALID_IP_REGEX = "^([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.(([0-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.){2}([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))$"; /** * 严格匹配 example: * jdbc:MysqL://localhost:3306/db_name?user=root&password=&useUnicode=true&characterEncoding=utf8&autoReconnect * =true&failOverReadOnly=false */ public static final String VALID_MysqL_LOCALHOST_URL_REGEX_STRICT = "^(jdbc:MysqL://localhost:)([1-9]+[0-9]*)+/([a-zA-Z0-9_-]+)(\\?([a-zA-Z]+=[a-zA-Z0-9]+)(&[([a-zA-Z]+=[a-zA-Z0-9]+)]+)*)*"; /** * 严格匹配 * example: jdbc:MysqL://127.0.0.1:3306/db_name?user=root&password=&useUnicode=true&characterEncoding=utf8&autoReconnect */ public static final String VALID_MysqL_IPPORT_URL_REGEX_SCRICT = "^(jdbc:MysqL://)([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.(([0-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.){2}([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5]))):([1-9]+[0-9]*)+/([a-zA-Z0-9_-]+)(\\?([a-zA-Z]+=[a-zA-Z0-9]+)(&[([a-zA-Z]+=[a-zA-Z0-9]+)]+)*)*"; /** * example: jdbc:oracle:thin:@localhost:1521:orcl * */ public static final String VALID_ORACLE_URL_REGEX = ""; /** * 支持字母数字美元符下划线,首字母必须大写字母 */ public static final String VALID_CLASS_NAME_REGEX = "^[A-Z]+[a-z0-9$_]*"; /** * 模块名称只支持小写字母 */ public static final String VALID_MODULE_NAME_REGEX = "^([a-zA-Z]\\w*)+"; /** * example: com.vip.venus */ public static final String VALID_PACKAGE_NAME_REGEX = "[a-zA-Z]\\w*(\\.[a-zA-Z]\\w*)*"; /** * example: table1:Object1,table2:Object2 */ public static final String VALID_TABLE_CONFIG_REGEX = "(([a-zA-Z]\\w*:[a-zA-Z]\\w*)+(,[a-zA-Z]\\w*:[a-zA-Z]\\w*)*)+"; /** * */ public static final String VALID_OBJECT_NAME_REGEX = "^[A-Z]+[a-zA-Z0-9$_]*"; /** * 工程名不能包含\ / * ? < > . */ public static final String ILLEGLE_PROJECT_NAME = "[*\\\\<>?/\\.]+"; 原文链接:https://www.f2er.com/regex/360141.html