Splunk Search

How to remove a carriage return from a field

allen_edmondson
Explorer

I have outputted events in csv format, and have a field which has carriage returns in it. How can use regex to remove the returns only from the field, in the search. Thanks in advance,

Tags (2)

lguinn2
Legend

This should replace all carriage returns or linefeeds with a space in a field named myField:

yoursearchhere
| eval myField = replace (myField, "[\n\r]"," ")
| morestuffhere

If your data is from Windows and has CRLF in it, this will replace the CRLF with two spaces.

grijhwani
Motivator

A refinement would be to make the regex "[\n\r]+" which would see one or more carriage returns or line feeds (or any combination thereof) with a single space.

asimagu
Builder

do you have more than one carriage return in the field value??

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...