Splunk Search

Regex Pattern

svercelli
Path Finder

I'm fairly new to Regex and having a difficult time coming up with a pattern for my query. I need to match everything after the second period in all of these values but can't figure out how

TMS_KEP.Male_RTU2.Male_PRM1_GL_OUT
TMS_KEP.Male_RTU2.Male_PRM1_PS_IN
TMS_KEP.Female_RTU2.Female_WC8_RL_OUT
TMS_KEP.Male_RTU1.Male_WC3_FS_OUT
TMS_KEP.Male_RTU1.Male_WC5_FS_OUT

There are some slight variations in this but essentially I need a pattern that takes everything after the second period.

Any help is greatly appreciated.

1 Solution

skoelpin
SplunkTrust
SplunkTrust

Try this

... | rex \w+\.\w+\.(?<FIELD>\w+)

This will capture everything after the 2nd period and create a new field called FIELD

View solution in original post

gcusello
SplunkTrust
SplunkTrust

HI svercelli,
if your need is to take all the chars after the first dot of each row, this is your regex:

[^\.]*\.(?<All>.*)

your can test it at https://regex101.com/r/PTqtiI/1

if instead you need is to take all the chars after the second dot of each row, this is your regex:

([^\.]*\.){2}(?<All>.*)

your can test it at https://regex101.com/r/8gxaHO/1

Bye.
Giuseppe

0 Karma

skoelpin
SplunkTrust
SplunkTrust

Try this

... | rex \w+\.\w+\.(?<FIELD>\w+)

This will capture everything after the 2nd period and create a new field called FIELD

svercelli
Path Finder

This worked perfectly, Thank you.

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