clearMessages(); if (! is_string($value)) { $this->addMessage($this->translate('Invalid regex given, must be a string')); return false; } if (@preg_match($value, '') === false) { $this->addMessage(sprintf( $this->translate('Regex "%s" failed to compile: %s'), $value, preg_last_error_msg() )); return false; } return true; } }