Splunk Enterprise

How to replace backslash by double backslash using eval in search and props.conf

jay
Engager

for example :  C:\user\process  -->  C:\\user\\process

Labels (1)
Tags (1)
1 Solution

manan_amin
Explorer

In Eval, We can use string format function (replace) to replace "\" by two "\\". 

Here, We need to escape "\" two times,

One of the way to replace it,

 

props.conf 

EVAL-new_path = replace(path ,"(\\\\)","\\\\\1")

 

in Search Query:

| eval new_path = replace(path ,"(\\\\)","\\\\\1")

View solution in original post

manan_amin
Explorer

In Eval, We can use string format function (replace) to replace "\" by two "\\". 

Here, We need to escape "\" two times,

One of the way to replace it,

 

props.conf 

EVAL-new_path = replace(path ,"(\\\\)","\\\\\1")

 

in Search Query:

| eval new_path = replace(path ,"(\\\\)","\\\\\1")

Get Updates on the Splunk Community!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...