# Remove contents of field from another field

**URL:** <https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849>\
**Category:** Logstash\
**Created:** [March 7, 2018, 9:07am UTC](https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849 "2018-03-07T09:07:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenoid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xenoid/32/20672_2.png) [@xenoid](https://discuss.elastic.co/u/xenoid)\
**Post date:** [March 7, 2018, 9:07am UTC](https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849/1 "2018-03-07T09:07:18Z")

</div>

Hello there,

I need to remove the contents of some field from another field.  
This seems like an easy procedure, but sadly I couldn't get it to work.  
This is what I tried, but it didn't work:

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

```

➡ Replace all the things in "message" matching with the contents of field "removethis" with "".

Essentially what I am looking for is something that can do this:

```
Field [message] = "Hello, I am Bob"
Field [removethis] = "Bob"

***FILTER MAGIC***

Field [message] after filter= "Hello, I am "

```

I hope you can help me. 🕶

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 7, 2018, 9:17am UTC](https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849/2 "2018-03-07T09:17:09Z")

</div>

Have you tried

```
gsub => ["message", "%{removethis}", ""]

```

?

---

<div class="post-metadata">

**Author:** ![xenoid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xenoid/32/20672_2.png) [@xenoid](https://discuss.elastic.co/u/xenoid)\
**Post date:** [March 7, 2018, 12:18pm UTC](https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849/3 "2018-03-07T12:18:57Z")

</div>

Yep, that's it.  
Thank you!  
Sometimes it's _that_ simple 😁

---

<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 4, 2018, 12:19pm UTC](https://discuss.elastic.co/t/remove-contents-of-field-from-another-field/122849/4 "2018-04-04T12:19:01Z")

</div>

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