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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...