code: 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;
          }
      }
docs: Exception safe regex match (to protect against malformed expressions)