Splunk Search

How do I write the regex to extract information within parenthesis?

BC88
New Member

Hey there,

I have been banging my head over this issue. Basically, I am searching a sourcetype for, let's call it, "X".

This search returns something along the lines of:

"Useless data here (Important Data)"

I am trying to display all of the information inside the parenthesis. I was looking at rex and regex and couldn't figure out how to word the syntax.

Any help would be appreciated!

0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi BC88,

based on your provided example run this regex:

 your base search here sourcetype=X |rex "\((?<myData>[^\)]+)\)" | ...

This will create a new field called myData which you can rename if needed 😉

Hope this helps ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi BC88,

based on your provided example run this regex:

 your base search here sourcetype=X |rex "\((?<myData>[^\)]+)\)" | ...

This will create a new field called myData which you can rename if needed 😉

Hope this helps ...

cheers, MuS

sjbriggs
Path Finder

Struggled with this for two days until I found your answer. Thanks!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

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 ...