error($this->messageInvalid); return false; } // escape '/' since Zabbix server treats them as literal characters. $value = str_replace('/', '\/', $value); // validate through preg_match $error = false; set_error_handler(function ($errno, $errstr) use (&$error) { if ($errstr != '') { $error = $errstr; } }); preg_match('/'.$value.'/', ''); restore_error_handler(); if ($error) { $this->error( $this->messageRegex, $value, str_replace('preg_match(): ', '', $error) ); return false; } return true; } }