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!

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...