# Error escaping slash

**URL:** <https://discuss.elastic.co/t/error-escaping-slash/344169>\
**Category:** Logstash\
**Created:** [September 30, 2023, 10:06am UTC](https://discuss.elastic.co/t/error-escaping-slash/344169 "2023-09-30T10:06:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Lopez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_lopez/32/50639_2.png) [@Daniel\_Lopez](https://discuss.elastic.co/u/Daniel_Lopez)\
**Post date:** [September 30, 2023, 10:06am UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/1 "2023-09-30T10:06:25Z")

</div>

I'm using, logstash 8.9.1 or version 7.14.1, with pipelines managed by kibana in version 8, and 7 with local configuration, having the same result

I have this config to remove \ from the message:

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

```

but i'm getting this error:

`:exception=>#<RegexpError: premature end of char-class: /[\]/>`

I tried `\[\\\]` to scape [] charachters, runs, but doesn't match with \

could any test?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 1, 2023, 6:47pm UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/2 "2023-10-01T18:47:10Z")

</div>

Hi @Daniel_Lopez

perhaps try

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

---

<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:** [October 1, 2023, 7:34pm UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/3 "2023-10-01T19:34:21Z")

</div>

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

```

That works for me with a local configuration for logstash 8.9. I wonder if something in centralized pipeline management is eating the escape.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 1, 2023, 7:46pm UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/4 "2023-10-01T19:46:29Z")

</div>

I cheated and did not really try logstash I did a quick test with the ingest pipeline gsub .. which did not work as shown but did work with the 4 `\`... Now curious what's going on?

---

<div class="post-metadata">

**Author:** ![Daniel\_Lopez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_lopez/32/50639_2.png) [@Daniel\_Lopez](https://discuss.elastic.co/u/Daniel_Lopez)\
**Post date:** [October 2, 2023, 7:02am UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/5 "2023-10-02T07:02:37Z")

</div>

I though i tested it, it is working with ` [\\\\]`, thanks a lot guys

---

<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:** [October 30, 2023, 7:02am UTC](https://discuss.elastic.co/t/error-escaping-slash/344169/6 "2023-10-30T07:02:38Z")

</div>

Closed on October 30, 2023, 7:02am UTC

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