Splunk Search

How to fetch values from a string using rex command

Puvi
New Member

Hi,

i have a field with values like AB101, I want to extract 101 separately into a new field

Tags (2)
0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval temp="AB101" 
| rex field=temp "(?P<result>[\d]+)"
0 Karma

kartm2020
Communicator

Try this.
It will fetch the number followed by digits.
| rex field=field_name "A-Z"

If you have non-capital words. try the below

| rex field=field_name "[A-Z]a-z"

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@Puvi,

Try

|rex field=field_name "(?<digits>\d+)"

where field_name is your field and digits is the new field

Happy Splunking!
0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@Puvi , please accept one of the answers which helped you or let's know if you need further help

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Splunk Lantern | Spotlight on Security: Adoption Motions, War Stories, and More

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

Splunk Cloud | Empowering Splunk Administrators with Admin Config Service (ACS)

Greetings, Splunk Cloud Admins and Splunk enthusiasts! The Admin Configuration Service (ACS) team is excited ...

Tech Talk | One Log to Rule Them All

One log to rule them all: how you can centralize your troubleshooting with Splunk logs We know how important ...