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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...