Dashboards & Visualizations

regex

SN1
Path Finder

 hi , I want to extract from  this date

12/11/2024

result should be 12/2024

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @SN1 ,

if this is a field (your_field), the easiest way it to use the eval functions, not a regex:

| eval date=strftime(strptime(your_field,"%m/%d/%Y"),"%m/%Y")

Ciao.

Giuseppe

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Apart from what @gcusello says, rex will only extract contiguous characters into a field, so what you are asking for is not possible in a single rex command.

gcusello
SplunkTrust
SplunkTrust

Hi @SN1 ,

if this is a field (your_field), the easiest way it to use the eval functions, not a regex:

| eval date=strftime(strptime(your_field,"%m/%d/%Y"),"%m/%Y")

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Best Strategies to Optimize Observability Costs

 Join us on Tuesday, May 6, 2025, at 11 AM PDT / 2 PM EDT for an insightful session on optimizing ...

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...