add ipv4,ipv5,domain regex
This commit is contained in:
@ -76,6 +76,15 @@ public class Regex {
|
|||||||
/** 护照 */
|
/** 护照 */
|
||||||
public static final String PASSPORT = "^[a-zA-Z0-9]{5,17}$";
|
public static final String PASSPORT = "^[a-zA-Z0-9]{5,17}$";
|
||||||
|
|
||||||
|
// IPv4 正则表达式
|
||||||
|
public static final String IPv4 = "^((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]?)$";
|
||||||
|
|
||||||
|
// IPv6 正则表达式(简化版)
|
||||||
|
public static final String IPv6 = "^([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}$|^::1$|^::$|^([0-9a-fA-F]{0,4}:){1,7}:$";
|
||||||
|
|
||||||
|
// 域名正则表达式(RFC 1123)
|
||||||
|
public static final String DOMAIN = "^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)*[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?$";
|
||||||
|
|
||||||
public static boolean isMatch(String regex, String text) {
|
public static boolean isMatch(String regex, String text) {
|
||||||
if (TimiJava.isEmpty(regex) || TimiJava.isEmpty(text)) {
|
if (TimiJava.isEmpty(regex) || TimiJava.isEmpty(text)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user