Splunk Search

regex help

gitingua
Communicator

hello my friends. 

how using regex can delete everything in bold

 

{"test": "  {   \n \"data\": \"check\",\n \"git_branch\": \"master\",\n \"git_repo_name\": \"reponame\",\n \"id\": 234,\n \"timestamp\": 16378522342,\n"}

 

output

 { \"data\": \"check\"\"git_branch\": \"master\", \"git_repo_name\": \"reponame\", \"id\": 3413, \"timestamp\": 16378522342 }

0 Karma

Gr0und_Z3r0
Contributor

Hi @gitingua , if you want a clean JSON data, then you can try something like this...

| makeresults 
| eval jsonData ="{\"test\": \"  {   \\n \\\"data\\\": \\\"check\\\",\\n \\\"git_branch\\\": \\\"master\\\",\\n \\\"git_repo_name\\\": \\\"reponame\\\",\\n \\\"id\\\": 234,\\n \\\"timestamp\\\": 16378522342,\\n } \"}"
| spath input=jsonData path=test output=result

Gr0und_Z3r0_0-1638075234209.png

 

Please vote up if it helps!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Does something like this work?

| rex mode=sed "s/\\n//g"
| rex mode=sed "s/\{\"test\":\s*\"\s*//g"
| rex mode=sed "s/\s*\"\}//g"
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

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