如果只有几个正则表达式,并且在编译时都知道它们,那么这就足够了:
private static final Pattern rx1 = Pattern.compile("..."), rx2 = Pattern.compile("..."), ...;return rx1.matcher(s).matches() || rx2.matcher(s).matches() || ...;如果它们更多,或者它们在运行时加载,则使用模式列表:
final List<Pattern> rxs = new ArrayList<>();for (Pattern rx : rxs) if (rx.matcher(input).matches()) return true;return false;



