Getting Data In

sed combined help

mcbradford
Contributor

I am using the following to clean up output:

rex mode=sed field=search_google2 "s/\%20/ /g";"s/\%5B/[/g" | rex mode=sed field=search_google2 "s/\%22/\"/g" | rex mode=sed field=search_google2 "s/\%5B/[/g" | rex mode=sed field=search_google2 "s/\%5D/]/g" | rex mode=sed field=search_google2 "s/\%2B/+/g" | rex mode=sed field=search_google2 "s/\%2C/,/g" | rex mode=sed field=search_google2 "s/\%3A/:/g" | rex mode=sed field=search_google2 "s/\%27/'/g" | rex mode=sed field=search_google2 "s/\%40/@/g" | rex mode=sed field=search_google2 "s/\%3B/;/g" | rex mode=sed field=search_google2 "s/\%25/%/g"

I am new to regex.... can I combine the regex into one statement instead of the multiple pipes?

Tags (1)
0 Karma

kristian_kolb
Ultra Champion

Well, sed supports the y command (character substitution), but since there is not a 1-to-1 mapping, I don't think you can apply that here.

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex
http://docs.splunk.com/Documentation/Splunk/5.0.2/Data/Anonymizedatausingconfigurationfiles#Through_...

However, you can put all of your regexes into props.conf SEDCMD statements, or through transforms, which would make the alteration permanent (may not be compatible with any requirements of keeping data in its original format, if you have such).

http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf
http://docs.splunk.com/Documentation/Splunk/5.0.2/Data/Anonymizedatausingconfigurationfiles#Through_...

Hope this helps,

Kristian

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...