Dashboards & Visualizations

regex

SN1
Explorer

 hi , I want to extract from  this date

12/11/2024

result should be 12/2024

Labels (1)
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!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...