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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...