PMA\libraries\config\Validator::validateRegex PHP Method

validateRegex() public static method

Validates regular expression
public static validateRegex ( string $path, array $values ) : array
$path string path to config
$values array config values
return array
    public static function validateRegex($path, $values)
    {
        $result = array($path => '');
        if (empty($values[$path])) {
            return $result;
        }
        if (function_exists('error_clear_last')) {
            /* PHP 7 only code */
            error_clear_last();
            $last_error = null;
        } else {
            // As fallback we trigger another error to ensure
            // that preg error will be different
            @strpos();
            $last_error = error_get_last();
        }
        $matches = array();
        // in libraries/ListDatabase.php _checkHideDatabase(),
        // a '/' is used as the delimiter for hide_db
        @preg_match('/' . Util::requestString($values[$path]) . '/', '', $matches);
        $current_error = error_get_last();
        if ($current_error !== $last_error) {
            $error = preg_replace('/^preg_match\\(\\): /', '', $current_error['message']);
            return array($path => $error);
        }
        return $result;
    }