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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...