Splunk Search

How to extract trailing numbers from a string with rex

hmbisht
Explorer

I'm trying to extract a string (alphabets and underscore) from a given string which can contain any number of numeric values in the end.

 rex field=_raw "type: (?.*)\d*$"

ex.
type: alphabets123 | alphabet
type: extract1 | extract
type: write_regex23| write_regex

0 Karma
1 Solution

Sukisen1981
Champion
| makeresults 
|  eval x="type: write_regex23" 
 | rex field=x "\:+(?<extract>.*?)\d+"

replace x by your source field and remove makeresults

View solution in original post

Sukisen1981
Champion
| makeresults 
|  eval x="type: write_regex23" 
 | rex field=x "\:+(?<extract>.*?)\d+"

replace x by your source field and remove makeresults

Sukisen1981
Champion

hi @hmbisht
Please accept the anser if it significantly helped resolve your issue or let us know if there are any more issues

0 Karma

hmbisht
Explorer

Thanks a lot @Sukisen1981

0 Karma
Get Updates on the Splunk Community!

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

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

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...

4 Ways the Splunk Community Helps You Prepare for .conf25

.conf25 is right around the corner, and whether you’re a first-time attendee or a seasoned Splunker, the ...