code: @Override
    public final boolean isValid(final String pvalue, final ConstraintValidatorContext pcontext) {
      if (StringUtils.isEmpty(pvalue)) {
        return true;
      }
      try {
        // execute regular expression, result doesn't matter
        "x".matches(pvalue);
        return true;
      } catch (final Exception pexception) {
        // regular expression is invalid
        return false;
      }
    }
docs: {@inheritDoc} check if given string is a valid regular expression.
  
  @see javax.validation.ConstraintValidator#isValid(java.lang.Object,
  javax.validation.ConstraintValidatorContext)