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 Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...