@Test public void safeRegexMatch_null() { assertFalse(Utils.safeRegexMatch(null, null)); assertFalse(Utils.safeRegexMatch(null, "")); assertFalse(Utils.safeRegexMatch(null, "abc")); }
public static boolean safeRegexMatch(String pattern, String value) { if (StringUtils.isNotBlank(pattern)) { if (value == null) { return false; } else { try { return Pattern.matches(pattern, value); } catch (PatternSyntaxException ex) { return false; } } } else { return false; } }
Utils { public static boolean safeRegexMatch(String pattern, String value) { if (StringUtils.isNotBlank(pattern)) { if (value == null) { return false; } else { try { return Pattern.matches(pattern, value); } catch (PatternSyntaxException ex) { return false; } } } else { return false; } } }
Utils { public static boolean safeRegexMatch(String pattern, String value) { if (StringUtils.isNotBlank(pattern)) { if (value == null) { return false; } else { try { return Pattern.matches(pattern, value); } catch (PatternSyntaxException ex) { return false; } } } else { return false; } } private  Utils(); }
Utils { public static boolean safeRegexMatch(String pattern, String value) { if (StringUtils.isNotBlank(pattern)) { if (value == null) { return false; } else { try { return Pattern.matches(pattern, value); } catch (PatternSyntaxException ex) { return false; } } } else { return false; } } private  Utils(); static boolean safeRegexMatch(String pattern, String value); static List<String> asList(String text); static String run(File wd, String cmd, String... args); static String toHexString(byte[] bytes); static String toHexString(byte[] bytes, int start, int len); static String toString(byte[] bytes); }
Utils { public static boolean safeRegexMatch(String pattern, String value) { if (StringUtils.isNotBlank(pattern)) { if (value == null) { return false; } else { try { return Pattern.matches(pattern, value); } catch (PatternSyntaxException ex) { return false; } } } else { return false; } } private  Utils(); static boolean safeRegexMatch(String pattern, String value); static List<String> asList(String text); static String run(File wd, String cmd, String... args); static String toHexString(byte[] bytes); static String toHexString(byte[] bytes, int start, int len); static String toString(byte[] bytes);  }