Splunk Search

How to create a regex that captures the first 6 characters of a mac address and removes the hyphen characters?

dkorlat
Explorer

I'm unable to create a regex that captures the first 6 characters of a mac address and removes the hyphen characters.

Here is the source data 00-2b-73-ab-1e-75
I need to change the source to 002B73

Here's my search | rex field =ClientId "(?) "

I'm getting stuck finding a regex statement that matches.

0 Karma
1 Solution

ddrillic
Ultra Champion

Something like - (?<one>.*)-(?<two>.*)-(?<three>.*).* and then you can concatenate the three of them...

alt text

View solution in original post

0 Karma

ddrillic
Ultra Champion

Something like - (?<one>.*)-(?<two>.*)-(?<three>.*).* and then you can concatenate the three of them...

alt text

0 Karma

dkorlat
Explorer

Thanks, I got it working by using (?<one>\w+)-(?<two>\w+)-(?<three>\w+)-(?<four>\w+)-(?<five>\w+)-(?<six>\w+)

Then I'll make upper case and concatenate one+two+three

0 Karma

ddrillic
Ultra Champion

Perfect @dkorlat.

0 Karma

dkorlat
Explorer

Thanks, I got it working by using [(?\w+)-(?\w+)-(?\w+)-(?\w+)-(?\w+)-(?\w+)

I will make it in upper case and concatenate one+two+three in Splunk.

Thanks

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...