code: 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
          );
      }
docs: Escapes value for use in expressions.
  
  @param string $string
  @param bool $allowWildcard Allow "*" in expression.
  
  @return mixed