# Gsub not work

**URL:** <https://discuss.elastic.co/t/gsub-not-work/99091>\
**Category:** Logstash\
**Created:** [September 1, 2017, 6:30am UTC](https://discuss.elastic.co/t/gsub-not-work/99091 "2017-09-01T06:30:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Orlenko](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Alexander\_Orlenko](https://discuss.elastic.co/u/Alexander_Orlenko)\
**Post date:** [September 1, 2017, 6:30am UTC](https://discuss.elastic.co/t/gsub-not-work/99091/1 "2017-09-01T06:30:12Z")

</div>

Hello,  
We have field, need cut symbol from end, we tru use gsub(regexp), but not cuting

mutate {replace =\> {type =\> "ztk\_login"}  
copy =\> { "host\_name" =\> "host\_name\_cut" }  
gsub =\> ["host\_name\_cut", "-ztk\d\d", " "]

```
                                         }

                                         }

```

t host\_name hbk1-ztk05  
t host\_name\_cut hbk1-ztk05  
we need first 4 symbol, "hbk1"

when run in debug mode for logstash, see message  
14:36:59.624 [[main]\>worker1] DEBUG logstash.filters.mutate - gsub mutation is only applicable for Strings, skipping {:field=\>"host\_name\_cut", :value=\>nil}  
Thanks

---

<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:** [September 29, 2017, 6:30am UTC](https://discuss.elastic.co/t/gsub-not-work/99091/2 "2017-09-29T06:30:27Z")

</div>

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