# How to escape new line character?

**URL:** <https://discuss.elastic.co/t/how-to-escape-new-line-character/294254>\
**Category:** Logstash\
**Created:** [January 13, 2022, 9:59am UTC](https://discuss.elastic.co/t/how-to-escape-new-line-character/294254 "2022-01-13T09:59:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![padamrai](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@padamrai](https://discuss.elastic.co/u/padamrai)\
**Post date:** [January 13, 2022, 9:59am UTC](https://discuss.elastic.co/t/how-to-escape-new-line-character/294254/1 "2022-01-13T09:59:12Z")

</div>

```auto
"MethodParameter" => "{\r\n \"getCardholderBalance\": {\r\n \"acquirer\": {\r\n      
\"id\": \"testdemo\",\r\n \"userId\": \"xxxxx\",\r\n \"password\": 
\"xxxxxxxxxxxxxxx\"\r\n },\r\n \"card\": {\r\n \"number\": 
\"5559590230901005\",\r\n \"referenceId\": \"394849349098\"\r\n },\r\n    
\"description\": \"YES\",\r\n \"includeSupplementaryCards\": \"Y\",\r\n    
\"sendClearCard\": \"Y\",\r\n \"applyFee\": \"N\",\r\n \"isForcedPost\": \"Y\"\r\n }\r\n}"

```

I want to escape \r\n and \ in the above string. Can you please help me how I can do this task?

```auto
mutate{
        gsub => ["MethodParameter", "\\r\\n ", ""]
}

```

I have tried this but it doing nothing.

---

<div class="post-metadata">

**Author:** ![padamrai](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@padamrai](https://discuss.elastic.co/u/padamrai)\
**Post date:** [January 13, 2022, 11:01am UTC](https://discuss.elastic.co/t/how-to-escape-new-line-character/294254/2 "2022-01-13T11:01:16Z")

</div>

Issue Resolved.

```auto
mutate{
        gsub => ["MethodParameter", "[\r\n]", ""]
}
mutate{
        gsub => ["MethodParameter", '\"', "'"]
}

```

---

<div class="post-metadata">

**Author:** ![oliver07](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@oliver07](https://discuss.elastic.co/u/oliver07)\
**Post date:** [January 13, 2022, 4:17pm UTC](https://discuss.elastic.co/t/how-to-escape-new-line-character/294254/3 "2022-01-13T16:17:22Z")

</div>

> [@padamrai](#):
>
> Issue [mybkexperience](https://mybkexperience.website/) Resolved.
> 
> ```auto
> mutate{
> gsub => ["MethodParameter", "[\r\n]", ""]
> }
> mutate{
> gsub => ["MethodParameter", '\"', "'"]
> }
> 
> ```

Thanks for the solution.

---

<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:** [February 10, 2022, 4:17pm UTC](https://discuss.elastic.co/t/how-to-escape-new-line-character/294254/4 "2022-02-10T16:17:26Z")

</div>

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