Splunk Search

How to use eval or other method in calculated fields to extract values into a new field?

reach2tushar
Explorer

Hi,

I am thinking of using the Calculated Fields option to extract one field.
I have following values in a field name "YOURFIELD"
Test_X
TestA_Y
TestBC_Z_all
I want to extract the characters before "_" in a new field "MYFIELD". The result will be:
Test
TestA
TestBC

Can please help me to extract this result in calculated fields using an EVAL function or any other method?

Tags (4)
0 Karma

Ayn
Legend
... | rex field=YOURFIELD "(?<MYFIELD>.+?)_"

Ayn
Legend

Yes, you can.

0 Karma

reach2tushar
Explorer

Thanks for the reply Ayn. Can we use RegEx in Calculated fields?

0 Karma
Get Updates on the Splunk Community!

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...