# Application order of gsub

**URL:** <https://discuss.elastic.co/t/application-order-of-gsub/179006>\
**Category:** Logstash\
**Created:** [April 30, 2019, 3:03am UTC](https://discuss.elastic.co/t/application-order-of-gsub/179006 "2019-04-30T03:03:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GGUERRA](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@GGUERRA](https://discuss.elastic.co/u/GGUERRA)\
**Post date:** [April 30, 2019, 3:03am UTC](https://discuss.elastic.co/t/application-order-of-gsub/179006/1 "2019-04-30T03:03:50Z")

</div>

Hi everyone, I would like to ask you a question about the gsub filter.

Replacements are applied in the order set in the array?

I have the following filter:

```
 mutate {
         gsub => ["message", "\"\"", "NULL",
                         "message", "\""," ",
                         "message", ",", ""]
 }

```

I need to replace the double quotes first, then delete the ones that are alone, ending with the commas replacement.

By placing this in order, is it done in that order?

I thank you in advance for the help, greetings!

---

<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:** [April 30, 2019, 2:20pm UTC](https://discuss.elastic.co/t/application-order-of-gsub/179006/2 "2019-04-30T14:20:15Z")

</div>

> [@GGUERRA](#):
>
> By placing this in order, is it done in that order?

It iterates over the array in groups of three, and arrays are ordered, so with the current implementation order is preserved.

---

<div class="post-metadata">

**Author:** ![GGUERRA](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@GGUERRA](https://discuss.elastic.co/u/GGUERRA)\
**Post date:** [May 5, 2019, 9:34pm UTC](https://discuss.elastic.co/t/application-order-of-gsub/179006/3 "2019-05-05T21:34:03Z")

</div>

Thanks a lot for your answer! Doing tests in effect does it that way

---

<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:** [June 2, 2019, 9:34pm UTC](https://discuss.elastic.co/t/application-order-of-gsub/179006/4 "2019-06-02T21:34:06Z")

</div>

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