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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...