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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...