Splunk Search

How to extract date separated by period

jkordis
New Member

Hi everyone,

I'm looking to take data such as 201908.1 from a field I've renamed in my search as "Operating System Version" and separate 2019, 08, and 1 from it.

I've looked on here for help in regex or using substr and haven't been able to make it work.

If anyone has any input it'd be appreciated!

0 Karma

mayurr98
Super Champion

here you go !
try this run anywhere search

| makeresults | eval "Operating System Version"="201908.1" | table "Operating System Version" | rex field="Operating System Version" "(?<year>^\d{4})(?<month>\d{1,2})\.(?<day>\d{1,2})"

In your env, you should try

..| rex field="Operating System Version" "(?<year>^\d{4})(?<month>\d{1,2})\.(?<day>\d{1,2})"
0 Karma

woodcock
Esteemed Legend

Like this:

... | rex field=<YourFieldNameHere> "^(?<year>\d{4})(?<month>\d{2})\.(?<day>\d+)$"
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...