Replace special character in stirng to other special character

Hi all

I have a case that i've been trying to do for a very long time.
I have a string that contain #0D#0A character that i want to replace them with the string \r\n
I've been trying to use gsub but it doesn't seem to be working at all.

Are there any solutions for what i'm trying to accomplish.

Thanks for your time.

Please share a sample of your message and what you have tried with gsub.

mutate{ gsub => ["message", "#0D#0A", "\r\n"] }


"original" => "something #0D#0Atest#0D#0A..."
"message" => "something \\r\\ntest\\r\\n...",

If you want single backslash, use ruby:

ruby { code => 'event.set("message", event.get("message").gsub("#0D#0A","\r\n"))' }

"message" => "something \r\ntest\r\n..."

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