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
Legend

@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
Legend

@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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...