Splunk Search

Splunk Regex Field Extractions

franciscoz1
Engager

When writing regex, where in the regex string am I supposed to add the (?<new_field>) string ?

I have included a sample regex string below, where in this string would I add (?<new_field>) ?

(?<=\:\[)(.*)(?=\])

Thanks !

Labels (2)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

If that is the exact regex and you are talking about using the rex command, then 

 

| rex "(?<new_field>(?<=\:\[)(.*)(?=\]))"

 

will extract the data between the [] into new_field

View solution in original post

franciscoz1
Engager

Worked like a charm, thank you !

0 Karma

bowesmana
SplunkTrust
SplunkTrust

If that is the exact regex and you are talking about using the rex command, then 

 

| rex "(?<new_field>(?<=\:\[)(.*)(?=\]))"

 

will extract the data between the [] into new_field

Get Updates on the Splunk Community!

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...