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!

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