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!

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 ...