Splunk Search

Extract Last 12 Characters

IRHM73
Motivator

Hi, I wonder whether someone could help me please.

I have the following string, which I'm trying to extract the last 12 characters i.e. A1B-CDEFB-NOT

claim-a-token|N5Y-UWLB-NOT

I've tried using the following regex /|(?[^\s]+) but unfortunately it extracts the whole string and not just the last 12 characters, and I'm a little unclear why.

Could someone perhaps look at this please and offer some guidance on where I've gone wrong.

Many thanks

Chris

Tags (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi IRHM73,
if you haven't spaces in your string, this is your regex:

(?<field>[^ ]{12})$

if instead you have spaces in your string, you could use this regex:

(?<field>.{12})$

Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi IRHM73,
if you haven't spaces in your string, this is your regex:

(?<field>[^ ]{12})$

if instead you have spaces in your string, you could use this regex:

(?<field>.{12})$

Bye.
Giuseppe

IRHM73
Motivator

Hi @cusello, thank you very much for this, it works great.

Many thanks and kind regards

Chris

0 Karma
Get Updates on the Splunk Community!

Part 2: A Guide to Maximizing Splunk IT Service Intelligence

Welcome to the second segment of our guide. In Part 1, we covered the essentials of getting started with ITSI ...

Part 1: A Guide to Maximizing Splunk IT Service Intelligence

As modern IT environments continue to grow in complexity and speed, the ability to efficiently manage and ...

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...