Splunk Search

Regex expression

hashsplunk
Loves-to-Learn Lots

prd-sso-data-science-711-3006-compute-role

dev-1000-535-aibench-mlops-service-compute-role

 

above are the field values . I need to extract the code 711-3006 & 1000-535

I have given the regular expression  |rex field="Role" ".*(?<Projectcode>\d{3,4}-\d+)" but its not fetching the code properly . It give 000-535 in the second value. Kindly help

Labels (1)
0 Karma

manjunathmeti
Champion

Try this:

| rex field=Role "\w+-(?<Projectcode>\d{3,4}-\d+)-\w+"

 

If this reply helps you, an upvote/like would be appreciated.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...