# How to replace 'special characters' with a logstash filter

**URL:** <https://discuss.elastic.co/t/how-to-replace-special-characters-with-a-logstash-filter/28240>\
**Category:** Logstash\
**Created:** [August 28, 2015, 10:08am UTC](https://discuss.elastic.co/t/how-to-replace-special-characters-with-a-logstash-filter/28240 "2015-08-28T10:08:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![DracoBlue](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dracoblue/32/4362_2.png) [@DracoBlue](https://discuss.elastic.co/u/DracoBlue)\
**Post date:** [August 29, 2015, 9:51pm UTC](https://discuss.elastic.co/t/how-to-replace-special-characters-with-a-logstash-filter/28240/2 "2015-08-29T21:51:45Z")

</div>

It seems like logstash has some issues, when it comes to escaping things. See:

[https://logstash.jira.com/browse/LOGSTASH-1377](https://logstash.jira.com/browse/LOGSTASH-1377)

and

> <https://github.com/elastic/logstash/issues/1645>

for more information.

According to: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub) the following should replace backslashes, question marks, hashes and minuses:

```
filter {
  mutate {
    gsub => [
      # replace backslashes, question marks, hashes, and minuses
      # with a dot "."
      "fieldname2", "[\\?#-]", "."
    ]
  }
}

```

Maybe it works, if you use "[\]" ?

---

_[View the full topic](https://discuss.elastic.co/t/how-to-replace-special-characters-with-a-logstash-filter/28240)._
