# Escape backslash logstash configuration

**URL:** <https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855>\
**Category:** Logstash\
**Created:** [September 16, 2020, 3:40pm UTC](https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855 "2020-09-16T15:40:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [September 16, 2020, 3:40pm UTC](https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855/1 "2020-09-16T15:40:20Z")

</div>

Hi,

I'm experiencing some troubles trying to split a string using backslash with the split plugin.

```
XXX\YYY

```

I'd like to use `split => ["field","\"]`

Quickly ran into escape problems as expected, according to the documentation i have tried to use the `config.support_escapes: true` and `["\\"]` but this dosen't really help as it looks like i'm escaping the double quotes and not the actual backslash.

Am i missing something ?

---

<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:** [September 16, 2020, 3:50pm UTC](https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855/2 "2020-09-16T15:50:54Z")

</div>

In a logstash configuration you cannot have a backslash at the end of a quoted string, it is always interpreted as escaping the quote.

In cases where a regexp is used, you can use a character group that contains a single backslash -- "[\\]"

If you want to do a split I think you will have to call a ruby filter.

```
ruby { code => 'event.set("field", event.get("field").split("\"))' }
```

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [September 16, 2020, 4:06pm UTC](https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855/3 "2020-09-16T16:06:12Z")

</div>

Hi,

Thanks for your reply, i had thought about using ruby but was concerned about performance, i managed to find a solution combining gsub and split plugins.

I frankly dont know what's the best for less performance impact one ruby or gsub and split.

---

<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 14, 2020, 4:06pm UTC](https://discuss.elastic.co/t/escape-backslash-logstash-configuration/248855/4 "2020-10-14T16:06:13Z")

</div>

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