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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...