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 the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

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