Validates if a value is a regular expression.