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!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...