Splunk Search

rex for extract codes

indeed_2000
Motivator

hi
what is the rex for extract all brackets contain this pattern
[AB_123] [ZXY_987]

1-check all brackets if start with AB_ extract this AB_123
2-check all brackets if start with ZXY_ extract this ZXY_987
3-put all this in single field that call "Codes"

any idea?
thanks

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "\[(?<Codes>(AB|ZXY)[^\]]+)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "\[(?<Codes>(AB|ZXY)[^\]]+)"
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 ...