Splunk Search

How to Extract the data after second special character?

Neel881
Path Finder

Hello,

I want the extract everything after the second slash(/) 

OR

Everything from the last till the first slash (/)     -- Both scenario works for me

 

Example - 

generation/abcd/giveandtake-messages-to-s

generation/xyz/giveandtake-messages-speedline-s

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex ".+/.+/(?<message>.*)"

View solution in original post

Neel881
Path Finder

Perfect! Thanks

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex ".+/.+/(?<message>.*)"

PickleRick
SplunkTrust
SplunkTrust

Restricting the firs two strings to character classes

[^/]+/[^/]+/(?<message>.*)

 gives big performance boost (prevents backtracking).

Neel881
Path Finder

Thank you! 

Can we do from the end as well? Right to left till the special charater?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
/(?<message>[^/]+)$

PickleRick
SplunkTrust
SplunkTrust

If you want to capture everything after the last slash, you can do something like

.*/(?<message>[^/]*)$

 

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...