# How use gsub in a Ruby code

**URL:** https://discuss.elastic.co/t/how-use-gsub-in-a-ruby-code/197166
**Category:** Logstash
**Created:** [August 28, 2019, 4:10pm UTC](https://discuss.elastic.co/t/how-use-gsub-in-a-ruby-code/197166 "2019-08-28T16:10:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Thiago\_Paiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_paiva/32/52326_2.png) [@Thiago\_Paiva](https://discuss.elastic.co/u/Thiago_Paiva)
#### Post date: [August 28, 2019, 4:10pm UTC](https://discuss.elastic.co/t/how-use-gsub-in-a-ruby-code/197166/1 "2019-08-28T16:10:42Z")

</div>

Hi friend,

I'm trying use gsub in ruby code. But my syntax didn't work.

`matches[x] = "GenericLog\tGenericDetail\t4\t2019-08-23 01:23:05"`

Code:

```
     matches.each_index{ |x|
            x.gsub(/(GenericLog).*\\t4\\t/, "" )
    }

```

Can Someone help?

---

<div class="post-metadata">

### Author: ![Thiago\_Paiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_paiva/32/52326_2.png) [@Thiago\_Paiva](https://discuss.elastic.co/u/Thiago_Paiva)
#### Post date: [August 28, 2019, 5:06pm UTC](https://discuss.elastic.co/t/how-use-gsub-in-a-ruby-code/197166/2 "2019-08-28T17:06:48Z")

</div>

I solved with:

```
 matches.each_index{ |x|
        matches[x] = matches[x].gsub(/GenericLogGenericLog\\tGenericDetail\\t4\\t/,"")
        }

```

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 25, 2019, 5:06pm UTC](https://discuss.elastic.co/t/how-use-gsub-in-a-ruby-code/197166/3 "2019-09-25T17:06:50Z")

</div>

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