# How to replace or remove hyphen (-) in a string field

**URL:** <https://discuss.elastic.co/t/how-to-replace-or-remove-hyphen-in-a-string-field/174633>\
**Category:** Logstash\
**Created:** [March 30, 2019, 8:44am UTC](https://discuss.elastic.co/t/how-to-replace-or-remove-hyphen-in-a-string-field/174633 "2019-03-30T08:44:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwjhou](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jwjhou](https://discuss.elastic.co/u/jwjhou)\
**Post date:** [March 30, 2019, 8:44am UTC](https://discuss.elastic.co/t/how-to-replace-or-remove-hyphen-in-a-string-field/174633/1 "2019-03-30T08:44:59Z")

</div>

I have a string field called `log_type`,  
which may contains string like "`-- INFO`".  
I'd like to remove hyphens (i. e. replace hyphen with empty string),  
how to do it?  
I have tried mutate gsub, like this:

```
mutate {
  gsub => ["log_type", "--", ""]
  ......

```

but the result will be "`-0- INFO`". Why?

---

<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:** [March 30, 2019, 12:40pm UTC](https://discuss.elastic.co/t/how-to-replace-or-remove-hyphen-in-a-string-field/174633/2 "2019-03-30T12:40:27Z")

</div>

What does you get from?...

```
mutate { gsub => ["log_type", "-", ""] }
```

---

<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:** [April 27, 2019, 12:40pm UTC](https://discuss.elastic.co/t/how-to-replace-or-remove-hyphen-in-a-string-field/174633/3 "2019-04-27T12:40:32Z")

</div>

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