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 Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...