Splunk Search

Replace from right side

zoh
Explorer

How to replace from right. for example I want to replace string "3:12:34" to "3 hours 12 minutes 34 seconds". but in case my input string is "12:34" only, it needs to be "12 minutes 34 seconds". It can only be achieved if I can replace ":" from right side first.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Here's how you could start:

... | eval step1 = replace(input, ":(\d\d)$", " \1 seconds")

The $ locks the matched part to the end of the string, essentially matching from the right side.

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...