Splunk Search

How to regex match?

kc_prane
Communicator

 Hi,

This is a raw log  Job=[IN-SNMMIS-DLY]], 

I am trying to build regex just the words " IN-SNMMIS-DLY]" 

and ignore the parenthesis  

 

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

 

| rex "Job=\[(?<job>[^\]]+)\]"

 

 

0 Karma

kc_prane
Communicator

Thankyou@ITWhisperer

0 Karma

yuanliu
SplunkTrust
SplunkTrust

I think @ITWhisperer pressed Enter before complete typing. (This happened to me today, too. Something on the forum interface might be off.)  Assuming the field Job is already extracted, a usable regex would be "^\[.+\]$".  To use in rex command:

|rex field=Job "^\[(?<Job_no_bracket>.+)\]$"

If Job is not extracted and you are only interested in the part inside brackets,

| rex "=\[(?<Job_no_bracket>.+)\]$"

This last one only works if there's nothing after "Job=[IN-SNMMIS-DLY]]" in _raw.

 

0 Karma

kc_prane
Communicator

Thanks a lot, @Yuanilu that regex worked for me.

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...