Splunk Search

Need help with a complicated field-extraction via regex

AnujaJadhav2
Explorer

want to extract a field in splunk however Splunk Regex won't work so I am writing my own Regex. However I am struggling to extract. Can someone please help?

My String:

Node ID=nbgcXYZdfdscxm2
Node ID=NBGDFDFCCXM2
Node ID=BURECXM2

Expected Output:

cXYZdfds
DFDFC
BURE

So far I was able to write this .*(?i)Node ID=^nbg

0 Karma
1 Solution

cpetterborg
SplunkTrust
SplunkTrust

This worked for me (validated using regex101.com):

(?i)Node ID=(nbg)?(?P<thing>\w+)cxm\d+

View solution in original post

cpetterborg
SplunkTrust
SplunkTrust

This worked for me (validated using regex101.com):

(?i)Node ID=(nbg)?(?P<thing>\w+)cxm\d+

AnujaJadhav2
Explorer

Just Perfect. Cannot imagine I wasted hours around this. Thank you so much.

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi AnujaJadhav2,

using regex101.com I ended up with this or regex:

 Node ID=(?i:(nbg))(.+)(?i:(cxm\d))|Node ID=(.+)(?i:(cxm\d))

the capturing group (.+) gives you the required results.

I'm sure this is not the best solution regex wise and some more clever guys haver better regexes, but it gives you something to start with 🙂

cheers, MuS

AnujaJadhav2
Explorer

This works very well in regex101 but it needs a capturing group for extraction. Nevertheless, thank you so much for your help.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...