Splunk Search

Why am I not able to use the regular expression value of my main search in subsearch rex?

saransakthi83
New Member

I tried to use the value of main search regex in subsearch rex .

Main search |rex "(?regular expression)"|append [search |rex "(?$val)"]
Main search |rex "(?regular expression)"|append [search |rex "(?regular expression)"]|search val=va1

both are not working. Please suggest what to do.

0 Karma

woodcock
Esteemed Legend

You do this with the map command like this:

search to set val | rex "(?<val>RegExHere)" | map search="search $val"

Or reverse your logic like this:

search [search to set val | rex "(?<val>RegExHere)" | return $val]
0 Karma

somesoni2
Revered Legend

You can't pass value from outer search to subsearch. What is your requirement here (samples/current query/expected output)?

0 Karma
Get Updates on the Splunk Community!

Splunk Classroom Chronicles: Training Tales and Testimonials (Episode 2)

Welcome to the "Splunk Classroom Chronicles" series, created to help curious, career-minded learners get ...

Index This | I am a number but I am countless. What am I?

January 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  Happy New Year! We’re ...

What’s New in Splunk Enterprise 9.4: Tools for Digital Resilience

PLATFORM TECH TALKS What’s New in Splunk Enterprise 9.4: Tools for Digital Resilience Thursday, February 27, ...