Splunk Search

Getting data out of an event with a regular expression

MattPainting
New Member

I am trying to figure out how to get data out of the event and into a field. I need to get all the data in brackets.

Sample data:

Run,jump,fly[walk]dog/cat

File storage ,[app - run] development

I want the result put into a new field and look like this:

walk

app - run

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @MattPainting,

if you want to extarct a field from a log, I hint to use the guided self extractor.

Anyway, using a regex, you can extract the value between square parenthesis putting it into a field:

| rex "\[(?<my_field>[^\]]+)"

Ciao.

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\[(?<result>[^\]]+)"

use max_match=0 if there is more than one bracketed result in an event

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