Splunk Search

Regex Help

theouhuios
Motivator

I am struggling with the regex match on the below pattern. I need to capture etl_fdaf_33424134 . Pretty much after the first _ . Any help?

/tmp/Jams/Apps/fgff_etl_fdaf_33424134.log 
/tmp/Jams/Apps/abc_etl_xyz_1111111.log 
Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

This should do:

_(?<fieldname>.*?)\.log

I've assumed you don't want the .log captured based on your example.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

This should do:

_(?<fieldname>.*?)\.log

I've assumed you don't want the .log captured based on your example.

martin_mueller
SplunkTrust
SplunkTrust

That's possible as well, just make sure to be precise in what you match afterwards:

Apps/[^_]+_(?<fieldname>.*?)\.log

Alternatively, use non-greedy quantifiers:

Apps/.+?_(?<fieldname>.*?)\.log

theouhuios
Motivator

That works. I wonder why I was trying to make it work from Apps/ . This is simple to write and understand. Thanks

0 Karma

theouhuios
Motivator

I am not able to make the regex stop at the first _ . Its always looking till the last one. Is there a way to force it match just on the first _

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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