# Replace newline for message fail

**URL:** <https://community.graylog.org/t/replace-newline-for-message-fail/23896>\
**Category:** Graylog Central (peer support)\
**Created:** [May 19, 2022, 9:52am UTC](https://community.graylog.org/t/replace-newline-for-message-fail/23896 "2022-05-19T09:52:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericwu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/ericwu/32/11131_2.png) [@ericwu](https://community.graylog.org/u/ericwu)\
**Post date:** [May 19, 2022, 9:52am UTC](https://community.graylog.org/t/replace-newline-for-message-fail/23896/1 "2022-05-19T09:52:58Z")

</div>

Hi all,

There are some message content in message field as below:

```auto
HoldMoney = 0,\n MaxLossMoney = 0,\n OddsMoney = 0,\n

```

I tried to replace the “\n” to the “space”, so I wrote the rule as below:

```auto
rule "remove newline"
when
    has_field("message")
then
    let new_message = regex_replace("\\n", to_string($message.message), " ", true);
    set_field("message", new_message);
end

```

but it doesn’t work, any idea ?

---

<div class="post-metadata">

**Author:** ![tmacgbay](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/tmacgbay/32/3878_2.png) [@tmacgbay](https://community.graylog.org/u/tmacgbay)\
**Post date:** [May 19, 2022, 2:46pm UTC](https://community.graylog.org/t/replace-newline-for-message-fail/23896/2 "2022-05-19T14:46:09Z")

</div>

Poking around I cam across [this post](https://graylog.zammad.com/help/en-us/15-pipeline-rule-samples/65-strip-newline-or-return-characters-from-message-field) - maybe it will help? IT talks about replacing the `\n` and `\r` separately… even though you haven’t mentioned the `\r`…

---

<div class="post-metadata">

**Author:** ![ericwu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/ericwu/32/11131_2.png) [@ericwu](https://community.graylog.org/u/ericwu)\
**Post date:** [May 20, 2022, 1:14am UTC](https://community.graylog.org/t/replace-newline-for-message-fail/23896/3 "2022-05-20T01:14:35Z")

</div>

@tmacgbay thanks a lot!!I’ll try it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [June 3, 2022, 1:15am UTC](https://community.graylog.org/t/replace-newline-for-message-fail/23896/4 "2022-06-03T01:15:31Z")

</div>

Closed on June 3, 2022, 1:15am UTC

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