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!

Security Professional: Sharpen Your Defenses with These .conf25 Sessions

Sooooooooooo, guess what. .conf25 is almost here, and if you're on the Security Learning Path, this is your ...

First Steps with Splunk SOAR

Our first step was to gather a list of the playbooks we wanted and to sort them by priority.  Once this list ...

How To Build a Self-Service Observability Practice with Splunk Observability Cloud

If you’ve read our previous post on self-service observability, you already know what it is and why it ...