org.whitesource.utils.WssStringUtils Maven / Gradle / Ivy
package org.whitesource.utils;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class WssStringUtils {
public static boolean isMatchingPattern(String[] stringsSet, Collection regexSet) {
for (String str : stringsSet) {
if (isMatchingPattern(str, regexSet)) {
return true;
}
}
return false;
}
public static boolean isMatchingPattern(String str, String[] regexSet) {
return isMatchingPattern(str, Arrays.asList(regexSet));
}
public static boolean isMatchingPattern(String str, Collection regexSet) {
for (String regex : regexSet) {
if (StringUtils.isNotBlank(str)) {
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(str);
if (m.matches()) {
return true;
}
}
}
return false;
}
}