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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...