Splunk Search

How to edit my rex search to extract field values with a hyphen?

edrivera3
Builder

Hi

I am extracting a field named revision from raw data and the only possible field values are 1 or 2 consecutive upper case letters or a hyphen e.g.(A,B,AC,GF, -). I tried the following, but it didn't extract the field values with a hyphen:

 | rex field=_raw " Revision  (?[-A-Z]{1,2})" 
0 Karma
1 Solution

somesoni2
Revered Legend

Try this (assuming your data looks like this " some data Revision A" OR " some data Revision AB" OR " some data Revision -")

   your base search | rex " Revision\s+(?<Revision>[-A-Z]{1,2})

View solution in original post

somesoni2
Revered Legend

Try this (assuming your data looks like this " some data Revision A" OR " some data Revision AB" OR " some data Revision -")

   your base search | rex " Revision\s+(?<Revision>[-A-Z]{1,2})

edrivera3
Builder

That is what I did and it's correct. My error was that I didn't noticed that there is a space before the hyphen and the single upper case letter so I changed the regex and it worked. Thanks (I am going to accept your answer!)

| rex " Revision (?[A-Z]{2,2}|\s\W|\s[A-Z])" 

edrivera3
Builder

For some reason, it doesn't appear the angle bracket with the word "revision".

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...