Splunk Search

Replace square brackets and leave original value

korstiaans
Explorer

Hi All,

I have a field with the following value:

[ "842cef72-745d-463c-8b49-ce16ccc5ebd2" ]

I'd like to get rid of the square brackets and the quotes ending up with:

842cef72-745d-463c-8b49-ce16ccc5ebd2

Labels (2)
0 Karma
1 Solution

clintla
Contributor

Sorry- added incorrectly \

(?<CAPTURE>[a-z0-9-]+)

View solution in original post

michel_wolf
Path Finder

Hi korstiaans,

you can try this:

|makeresults
|eval sample_field="[ \"842cef72-745d-463c-8b49-ce16ccc5ebd2\" ]"
|rex field=sample_field "\[\s\"(?<new_field>.*)?\""

I don´t know if you have realy spaces between the [ and "

Michel

clintla
Contributor

(?<CAPTURE>[a-z0-9-\]+)

0 Karma

clintla
Contributor

Sorry- added incorrectly \

(?<CAPTURE>[a-z0-9-]+)

korstiaans
Explorer

@clintla Thanks, works like a charm. 

0 Karma

korstiaans
Explorer

Hi Michel,

That doesn't work, but it's probably, because the field is a little weird formatted. It looks like this in a table:

 

splunk_answers.png

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...