protected function escapeExpressions($string, $allowWildcard = false)
    {
        if ($allowWildcard) {
            $reservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\ ');
        } else {
            $reservedCharacters = preg_quote('+-&|!(){}[]^"~*?:\\ ');
        }

        return preg_replace_callback(
            '/([' . $reservedCharacters . '])/',
            function ($matches) {
                return '\\' . $matches[0];
            },
            $string
        );
    }
protected function escapeExpressions($string, $allowWildcard = false)
    {
        if ($allowWildcard) {
            $reservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\ ');
        } else {
            $reservedCharacters = preg_quote('+-&|!(){}[]^"~*?:\\ ');
        }

        return preg_replace_callback(
            '/([' . $reservedCharacters . '])/',
            function ($matches) {
                return '\\' . $matches[0];
            },
            $string
        );
    }
protected function escapeExpressions ( $ string , $ allowWildcard = false ) { if ( $ allowWildcard ) { $ reservedCharacters = preg_quote ( '+-&|!(){}[]^"~?:\\ ' ) ; } else { $ reservedCharacters = preg_quote ( '+-&|!(){}[]^"~*?:\\ ' ) ; } return preg_replace_callback ( '/([' . $ reservedCharacters . '])/' , function ( $ matches ) { return '\\' . $ matches [ 0 ] ; } , $ string ) ; }
Escapes value for use in expressions.

@param string $string
@param bool $allowWildcard Allow "*" in expression.

@return mixed
Escapes value for use in expressions .