Splunk Search

What regular expression should I use to eliminate a character in the field value?

kiran331
Builder

Hi

What Regex do I have to use to eliminate a character in the field value?

eg:
G0:1K:BF:04:12:2C
expected: G01KBF04122C

0 Karma
1 Solution

sundareshr
Legend

Replace should do it as well

| eval newfield=replace(oldfield, ":", "")

View solution in original post

0 Karma

sundareshr
Legend

Replace should do it as well

| eval newfield=replace(oldfield, ":", "")
0 Karma

schose
Builder

regex should work as descripted. another possibility is to crate/eval a new field

your_search | eval macnew = replace(mac_field, ":","")

Regards,

Andreas

0 Karma

inventsekar
SplunkTrust
SplunkTrust

Please check this

| rex mode=sed "s/\://g"

for learnings,
mode=sed --- to update rex to use sed mode
s/ --- search for
":" ---- escaped ":"
"//" ---- replace it with "empty" string (remove)
/g ----- do this search and replace globally.

alt text

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