Splunk Search

How to make substring using rex

splunkkid
Path Finder

Hello,

 

I am currently confront some problem here.

I want to substring data in specific column using rex.

 

The column's data looks like below(All same or similar style).

"****-****-**POD4-***"

 

In above case, all  I need is the number after the word POD. ( * means some alphabets)

 

Any ideas? 

Thank you.

 

Labels (1)
0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust

replace <choosefield> with field name from which you want to extract number after word POD. number will be extracted to new field called "podnumber"

| rex field=<choosefield> "POD(?<podnumber>\d+)"
————————————
If this helps, give a like below.

View solution in original post

thambisetty
SplunkTrust
SplunkTrust

replace <choosefield> with field name from which you want to extract number after word POD. number will be extracted to new field called "podnumber"

| rex field=<choosefield> "POD(?<podnumber>\d+)"
————————————
If this helps, give a like below.

splunkkid
Path Finder

@thambisetty 

 

Thanks! This worked exactly how I want.

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=column "POD(?<number>\d+)\-"

where column is the field name your data is in.

Is it always POD? If not, is it always ****-****-**POD4-***  4 letters "-" 4 letters "-" 2 letters 3 characters number (at least 1 digit) "-" 3 letters?

splunkkid
Path Finder

@ITWhisperer 

First, Thanks for your answer.

 

And I tried like below

MYSEARCH | rex field=pod "pod(?<number>\d+)" | sort podnumber | table pod podnumber

 

Erased the part "\-" because that makes no results, although i don't know why.

 

And * part could be different by row, so it doesn't really helpful I guess.

 

 

0 Karma
Get Updates on the Splunk Community!

Splunk App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...