Splunk Search

How to edit my rex command to replace a string?

chintan_shah
Path Finder

Hi,
I want to replace the string "\x00" with spaces.
"CP REQUESTED \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" and i tried below commands but it didn't work.

rex mode=sed field=EXCP_MSG "s/\\x00/ /g"
replace \\x00 WITH " " IN EXCP_MSG|stats count  by EXCP_MSG

Can anyone help me and also which command is better to use?

0 Karma
1 Solution

woodcock
Esteemed Legend

The first rule of RegEx and backslashes: if at first you don't succeed, add another backslash:

| makeresults 
| eval EXCP_MSG="CP REQUESTED \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 

| rename COMMENT AS "Everything above fakes sample data; everything below is your solution"

| rex mode=sed field=EXCP_MSG "s/\\\\x00/ /g"

View solution in original post

woodcock
Esteemed Legend

The first rule of RegEx and backslashes: if at first you don't succeed, add another backslash:

| makeresults 
| eval EXCP_MSG="CP REQUESTED \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 

| rename COMMENT AS "Everything above fakes sample data; everything below is your solution"

| rex mode=sed field=EXCP_MSG "s/\\\\x00/ /g"

chintan_shah
Path Finder

Thanks Woodcock

0 Karma
Get Updates on the Splunk Community!

Security Professional: Sharpen Your Defenses with These .conf25 Sessions

Sooooooooooo, guess what. .conf25 is almost here, and if you're on the Security Learning Path, this is your ...

First Steps with Splunk SOAR

Our first step was to gather a list of the playbooks we wanted and to sort them by priority.  Once this list ...

How To Build a Self-Service Observability Practice with Splunk Observability Cloud

If you’ve read our previous post on self-service observability, you already know what it is and why it ...