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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...