Splunk Search

Use named backreference in the subsequent rex command

Murali2888
Communicator

Hi All,

Can you let me know how we can use a named backreference in the subsequent rex command? That is pass the value of the named backreference to the next rex command.

I am trying something like below which is not providing the desired result.

rex "<tag1>(?P<NamedField1>[^<]+" | rex "<tag2>?(P=NamedField1)</tag2><tag3>(?P<NamedField2>)" | table NamedField2

If someone could point out some documentation around this that would be very helpful.

0 Karma

maciep
Champion

Not exactly what you're asking, but you can use \n to represent a previously captured group in the same rex command. So in your case, something like

rex "<tag1>(?P<NamedField1>[^<]+").+<tag2>\1</tag2><tag3>(?P<NamedField2>)" 

Although I'm pretty sure i found a way to substitute field names in the rex too, but don't remember and could be mistaken.

0 Karma

Murali2888
Communicator

Thanks maciep.

I had this option, but unfortunately the xml structure is quite redundant and complex which would not allow using a single rex command. Nevertheless, I had found some workaround with eval command.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...