code: private static boolean matchRuleRegex(String regex, String value) {
  
          if (value == null) {
              value = "";
          }
  
          if (regex == null) {
              return true;
          }
          if ((regex.length() > 0) && (regex.charAt(0) == '!')) {
              return !value.matches(regex.substring(1));
          } else {
              return value.matches(regex);
          }
      }
docs: Matches a string against a regex, and inverts the match if the regex starts with a '!'.<p>
  
  @param regex the regular expression
  @param value the string to be matched
  
  @return true if the validation succeeded