Splunk Search

How to split/extract substring before the first - from the right side of the string

keshavgupta
Engager
Spoiler
How to split/extract substring before the first - from the right side of the field on splunk search

For ex: My field hostname contains

Hostname = abc-xyz
Hostname = abc-01-def
Hostname = pqr-01

I want to see like below .

abc
abc-01
pqr

Please help me.

Labels (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<host>[^\-]+)\-"
0 Karma
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...