Splunk Search

How to extract a field using rex that contains backslash and double quotation marks?

retro-bloke
Explorer

in the raw event there is a line that goes Brand\="xyz"

 

What's the rex command I can use to extract this in my search?

 

If possible, I'd like to remove the \ and "" from the extraction itself.

Labels (1)
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @retro-bloke ... May i know if you are looking for a rex search query 

or..

you want to update the props.conf file for the purpose of field extraction, please confirm, thanks.

0 Karma

retro-bloke
Explorer

Hi @inventsekar, I am looking for a rex search query

0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @retro-bloke 

Please check this: (you may need to modify little bit, depending on your logs.. if this does not work, pls give us some sample events)

 

| makeresults | eval temp="the test event is Brand\=\"xyz\"" 
|rex field=temp "(?P<brand>\w+)\"" 
|table temp brand

 

rex-brand.png

0 Karma

retro-bloke
Explorer

I found that this also works

 

rex "Brand\\\=\"(?<brand>.*?)\""

 

the triple quotation marks escape the \, the \" surrounding the () handles the quotation marks in the event itself.

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 ...