# Proper RegEx with Mutate\>GSub

**URL:** <https://discuss.elastic.co/t/proper-regex-with-mutate-gsub/229679>\
**Category:** Logstash\
**Created:** [April 24, 2020, 3:11pm UTC](https://discuss.elastic.co/t/proper-regex-with-mutate-gsub/229679 "2020-04-24T15:11:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 24, 2020, 5:25pm UTC](https://discuss.elastic.co/t/proper-regex-with-mutate-gsub/229679/2 "2020-04-24T17:25:30Z")

</div>

Having a backslash at the end of a string requires a trick. Use a character group that just includes backslash...

```
mutate { gsub => ["[user][name]", "\w+[\\]{2}", "" ] }
```

---

_[View the full topic](https://discuss.elastic.co/t/proper-regex-with-mutate-gsub/229679)._
