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!

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2025 SplunkTrust is officially open! If you ...

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...