Splunk Search

What is the regular expression to extract "a1234567" from my event?

sravankaripe
Communicator

Please help me with regular expression
i want to extract a1234567

"INDV=1234566|RSPAR|a1234567|RSPAR"
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

hi sravankaripe,
you can use it on row events

\d+\|\w+\|(?<your_field>[^\|]*)

or using a rex command

| rex field=INDV "\d+\|\w+\|(?<your_field>[^\|]*)"

You can see it at https://regex101.com/r/Ve484u/1

Bye.
Giuseppe

View solution in original post

0 Karma

twinspop
Influencer

I would consider using the split and mvindex commands for this, assuming INDV is being extracted already:

... | eval my_field=mvindex(split(INDV,"|"),2)

With regex:

... | rex field=INDV "RSPAR\|(?[^|]+)"

But that really depends on the consistency of the data around your target extraction.

0 Karma

gcusello
SplunkTrust
SplunkTrust

hi sravankaripe,
you can use it on row events

\d+\|\w+\|(?<your_field>[^\|]*)

or using a rex command

| rex field=INDV "\d+\|\w+\|(?<your_field>[^\|]*)"

You can see it at https://regex101.com/r/Ve484u/1

Bye.
Giuseppe

0 Karma

sravankaripe
Communicator

| rex field=_raw "\d+|\w+|(?[^|]*)"
this worked for me Thanks

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...