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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

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