Splunk Search

How to extract two characters before last set of numbers in a string?

jenkinsta
Path Finder

Tried many variations but just cant get it right. 

Example Data:
onetwoap321.site
onethreap3ua.somesite
oneforpd210.site
one3ninaw1u.site

The string may or may not have characters after the last set of numbers. There may be another number but will be seperated by at least 2 letters before the last set of numbers. 

{string}{number optional}{2 letters}{number}{optional characters}{may or may not have . at end}

The two letters is what I want to capture in a field called Code. 

| rex field=Name "^(?<Code>[^.]+)"

Thanks for any help. 

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=Name ".*(?<Code>[a-zA-Z]{2})\d"

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=Name ".*(?<Code>[a-zA-Z]{2})\d"
0 Karma

jenkinsta
Path Finder

I was so close at one point but didnt have the trailing \d. Thanks so much

0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...