code: public static boolean validateRegex(String value, String regex, boolean allowEmpty) {
  
          if (CmsStringUtil.isEmptyOrWhitespaceOnly(value)) {
              return allowEmpty;
          }
          Pattern pattern = Pattern.compile(regex);
          Matcher matcher = pattern.matcher(value);
          return matcher.matches();
      }
docs: Validates a value against a regular expression.<p>
  
  @param value the value to test
  @param regex the regular expression
  @param allowEmpty if an empty value is allowed
  
  @return <code>true</code> if the value satisfies the validation