# Gsub not working to remove | (vertical bar/piper)

**URL:** <https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703>\
**Category:** Logstash\
**Created:** [February 13, 2018, 7:54pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703 "2018-02-13T19:54:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kabilan](https://avatars.discourse-cdn.com/v4/letter/k/ecccb3/32.png) [@kabilan](https://discuss.elastic.co/u/kabilan)\
**Post date:** [February 13, 2018, 7:54pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/1 "2018-02-13T19:54:54Z")

</div>

hey i've been religiously trying to figure out how to remove the vertical bar from my log entries.

```
		gsub => ["message", "/\|/g", " "] 

```

no luck

---

<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:** [February 13, 2018, 9:00pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/2 "2018-02-13T21:00:19Z")

</div>

```
gsub => ["message", "\|", " "]
```

---

<div class="post-metadata">

**Author:** ![kabilan](https://avatars.discourse-cdn.com/v4/letter/k/ecccb3/32.png) [@kabilan](https://discuss.elastic.co/u/kabilan)\
**Post date:** [February 13, 2018, 9:18pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/3 "2018-02-13T21:18:53Z")

</div>

I tried that first, no luck

---

<div class="post-metadata">

**Author:** ![kabilan](https://avatars.discourse-cdn.com/v4/letter/k/ecccb3/32.png) [@kabilan](https://discuss.elastic.co/u/kabilan)\
**Post date:** [February 13, 2018, 9:20pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/4 "2018-02-13T21:20:11Z")

</div>

eg.

local0--info--AFA-STE--CEF--2018-02-10T12:00:33-05:00--0|AlgoSec|FireFlow|v6.11.420-b159|Log|Log|0|

trying to replace the | with a empty space

---

<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:** [February 13, 2018, 9:25pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/5 "2018-02-13T21:25:37Z")

</div>

Works for me. With this config

```
input { stdin {} }
filter { mutate { gsub => ["message", "\|", " "] } }
output { stdout { codec => rubydebug } }
```

run using

```
echo 'local0--info--AFA-STE--CEF--2018-02-10T12:00:33-05:00--0|AlgoSec|FireFlow|v6.11.420-b159|Log|Log|0|' | /usr/share/logstash/bin/logstash -f test.conf
```

I get

```
"message" => "local0--info--AFA-STE--CEF--2018-02-10T12:00:33-05:00--0 AlgoSec FireFlow v6.11.420-b159 Log Log 0 "
```

---

<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:** [March 13, 2018, 9:26pm UTC](https://discuss.elastic.co/t/gsub-not-working-to-remove-vertical-bar-piper/119703/6 "2018-03-13T21:26:17Z")

</div>

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