forked from plusone/plusone-commons
重构代码,调整 API。
This commit is contained in:
@@ -2,20 +2,33 @@ package xyz.zhouxy.plusone.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
|
||||
public class RegexUtil {
|
||||
|
||||
private RegexUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
public static boolean matches(CharSequence input, String regex) {
|
||||
return ReUtil.isMatch(regex, input);
|
||||
}
|
||||
|
||||
public static boolean matches(CharSequence input, String regex) {
|
||||
return Pattern.matches(regex, input);
|
||||
public static boolean matches(CharSequence input, Pattern regex) {
|
||||
return ReUtil.isMatch(regex, input);
|
||||
}
|
||||
|
||||
public static boolean matchesOr(CharSequence input, String... regexs) {
|
||||
boolean isMatched;
|
||||
for (String regex : regexs) {
|
||||
isMatched = Pattern.matches(regex, input);
|
||||
isMatched = matches(input, regex);
|
||||
if (isMatched) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matchesOr(CharSequence input, Pattern... regexs) {
|
||||
boolean isMatched;
|
||||
for (Pattern regex : regexs) {
|
||||
isMatched = matches(input, regex);
|
||||
if (isMatched) {
|
||||
return true;
|
||||
}
|
||||
@@ -26,11 +39,26 @@ public class RegexUtil {
|
||||
public static boolean matchesAnd(CharSequence input, String... regexs) {
|
||||
boolean isMatched;
|
||||
for (String regex : regexs) {
|
||||
isMatched = Pattern.matches(regex, input);
|
||||
isMatched = matches(input, regex);
|
||||
if (!isMatched) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean matchesAnd(CharSequence input, Pattern... regexs) {
|
||||
boolean isMatched;
|
||||
for (Pattern regex : regexs) {
|
||||
isMatched = matches(input, regex);
|
||||
if (!isMatched) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private RegexUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user