# How can i replace multiple special characters in all fields?

**URL:** <https://discuss.elastic.co/t/how-can-i-replace-multiple-special-characters-in-all-fields/276922>\
**Category:** Logstash\
**Created:** [June 24, 2021, 12:21pm UTC](https://discuss.elastic.co/t/how-can-i-replace-multiple-special-characters-in-all-fields/276922 "2021-06-24T12:21:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 24, 2021, 7:00pm UTC](https://discuss.elastic.co/t/how-can-i-replace-multiple-special-characters-in-all-fields/276922/2 "2021-06-24T19:00:14Z")

</div>

If it is a fixed set of fields you could do it in a mutate filter. If you really want to do it to all fields and you do not know what those fields will be you would have to use ruby

```
    ruby {
        code => '
            event.to_hash.each { |k, v|
                if v.is_a? String
                    event.set(k, v.gsub("&Ccedil;", "Ç").gsub("&ccedil;", "ç").gsub("&#350;", "Ş").gsub("&#351;", "ş").gsub("&#304;", "İ").gsub("&#305;", "ı").gsub("&Uuml;", "Ü").gsub("&uuml;", "ü").gsub("&Ouml;", "Ö").gsub("&ouml;", "ö").gsub("&#286;", "Ğ").gsub("&#287;", "ğ"))
                end
            }
        '
    }

```

If you want to handle more HTML entities you might be better off rewriting that loop to use something like [htmlentities](https://rubygems.org/gems/htmlentities). If you need to handle fields nested in objects you would have to write a recursive function. There is an example of walking through all fields in an event [here](https://discuss.elastic.co/t/logstash-json-filter-plugin-values-as-string/256912/2).

---

_[View the full topic](https://discuss.elastic.co/t/how-can-i-replace-multiple-special-characters-in-all-fields/276922)._
