- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the rex command to extract the last value from a source field?
simona2121
Path Finder
09-16-2016
05:18 AM
Hi .. I need to extract back123 from the source field. pls provide the entire rex command needed to fetch back123 to a new field.
eg:
source = /opensource/final/back123
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
aaraneta_splunk

Splunk Employee
09-29-2016
05:49 PM
Hi @simona2121 - Looks like you have several answers to try out 🙂 If one of them has worked, please click "Accept" below the best answer to resolve this post. Thank you!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lukejadamec
Super Champion
09-29-2016
06:47 AM
Joining the answer party...
Try this
source = "*opensource*" | dedup source | rex field=source ".*\/(?<new>.*)" | table source, new
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lakromani
Builder
09-29-2016
03:23 AM
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

sundareshr
Legend
09-16-2016
07:11 AM
Let's make it an even 4
... | rex field=source "\/(?<folder>[^\/]*)$"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

woodcock
Esteemed Legend
09-16-2016
07:03 AM
Like this:
... | rex field=source ".*?(?<fn>[^\/]*)$"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

gcusello

SplunkTrust
09-16-2016
05:33 AM
Try this:
yoursearch | rex field=source ".*\/(?[^ ]+)" | table myfield
Bye.
Giuseppe
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
inventsekar

SplunkTrust
09-16-2016
05:25 AM
if that source is part of your event, then field=_raw is good.
yoursearch | rex field=_raw "final\/(?<rexField>.*)" | table rexField
if that source is splunk extracted source field, then field=source is good.
yoursearch | rex field=source "final\/(?<rexField>.*)" | table rexField
thanks and best regards,
Sekar
PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
Sekar
PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
