> For the complete documentation index, see [llms.txt](https://knowledgebase.ajaxsearchpro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.ajaxsearchpro.com/miscellaneous/other/replace-or-remove-characters-from-search-phrase.md).

# Replace or remove characters from search phrase

By default the plugin allows searching any character without restriction. If you however need to replace (or remove) certain special characters, use the code below.

[What is this, and where do I put this custom code?](/safe-coding-guideline.md)

```php
add_filter('asp_query_args', 'asp_replace_characters', 10, 1);
function asp_replace_characters( $args ) {
  $characters = "',._-?!"; // Type characters one after another
  $replace_with = ' ';     // Replace them with this (space by default)

  $args['s'] = str_replace(str_split($characters), $replace_with, $args['s']);      

  return $args; 
}
```

Type the characters into the $characters variable, one after another. By default it replaces it with a space character. In case you want to remove those characters, change the

```
$replace_with = ' ';
```

with:

```
$replace_with = '';
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.ajaxsearchpro.com/miscellaneous/other/replace-or-remove-characters-from-search-phrase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
