Splunk Search

How to extract the substring from a string

febbi
Explorer

I want to extract the substring: "xenmobile" from string:  "update task to xenmobile-2021-11-08-19-created completed!", how can I get that?

Labels (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust
| makeresults
| eval foo = "update task to xenmobile-2021-11-08-19-created completed!"
| rex field=foo "update task to (?<bar>[^-]+)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| replace "xenmobile" WITH "" IN field
0 Karma

isoutamo
SplunkTrust
SplunkTrust
| makeresults
| eval foo = "update task to xenmobile-2021-11-08-19-created completed!"
| rex field=foo "update task to (?<bar>[^-]+)"
Get Updates on the Splunk Community!

Leveraging Detections from the Splunk Threat Research Team & Cisco Talos

  Now On Demand  Stay ahead of today’s evolving threats with the combined power of the Splunk Threat Research ...

New in Splunk Observability Cloud: Automated Archiving for Unused Metrics

Automated Archival is a new capability within Metrics Management; which is a robust usage & cost optimization ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...