code: def regexpr_validator(value):
      
      try:
          re.compile(value)
      except re.error:
          raise ValidationError(
              _('"%(value)s" is not a valid regular expression'),
              params={'value': value}
          )
docs: Test that ``value`` is a valid regular expression
  
          :param unicode value: A regular expression to test
          :raises ValidationError: if ``value`` is not a valid regular expression