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!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

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

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

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