Splunk Dev

Replace field value using rex

Nadhiyaa
Path Finder

XXXXXX y XXXXXX y

So this is my value of a field z . How to replace this with XXXXXX y.

Below is not working

rex mode=sed field=z "s/XXXXXX y XXXXXX y/XXXXXX y/g"

Tags (1)
0 Karma

jkat54
SplunkTrust
SplunkTrust

Try this:

rex mode=sed field=z "s/(XXXXXX\s+y)\s+XXXXXX\s+y/\1/g"

the \s+ should grab tabs and whitespace. The parens () and \1 will make the first part of that string a capture group, and use what is captured as the replacement.

0 Karma

493669
Super Champion

i tried this it seems to be working-

| makeresults |eval z="XXXXXX y XXXXXX y"|rex mode=sed field=z "s/XXXXXX y XXXXXX y/XXXXXX y/g"

what is expected output ..can you provide some details..

0 Karma

Nadhiyaa
Path Finder

when we do eval , it works .

when i do directly after the stats command ,it is not

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