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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...