# Gsub filter not working as expected for dot to underscore conversion

**URL:** <https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180>\
**Category:** Logstash\
**Created:** [October 12, 2018, 7:38am UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180 "2018-10-12T07:38:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [October 12, 2018, 7:38am UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180/1 "2018-10-12T07:38:00Z")

</div>

Hi All,

I have been trying to replace dots to underscores in the fieldname using gsub filter and didnt succeeded,  
here is my filter

```
mutate {
    gsub => [
        "caller_id.location.latitude", ".", "_"
        ]
}

```

there are no errors while executing logstash, but there is no change in the fieldname when i check the output in rubydebug.

Is there something i'm missing or gsub doesnot support this type of conversion, please advice.

Thanks  
Gauti

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [October 22, 2018, 2:24pm UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180/2 "2018-10-22T14:24:18Z")

</div>

The second string `"."` is converted to a regex so you will need to escape the dot.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [October 22, 2018, 3:55pm UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180/3 "2018-10-22T15:55:15Z")

</div>

@guyboertje how do i escape that dot? any idea??

Thanks  
Gauti

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [October 22, 2018, 4:55pm UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180/4 "2018-10-22T16:55:48Z")

</div>

Well you could [google it](https://www.google.co.uk/search?q=regex+escape+dot&oq=regex+escape+&aqs=chrome.3.69i57j0j69i60j0l3.12553j0j8&sourceid=chrome&ie=UTF-8)

It is `"\."`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 19, 2018, 5:05pm UTC](https://discuss.elastic.co/t/gsub-filter-not-working-as-expected-for-dot-to-underscore-conversion/152180/5 "2018-11-19T17:05:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
