Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex a date from the filename

jenner85
8 - Asteroid

Hi - I have these different formats of file name, how would you best get the date from it:

 

04 MC report - Apr 2018
04 MC report - Apr 2019
04 MC report - Apr 2020
04 MC report - Apr2015 Revised
04 MC report - Apr2016
05 MC report - May 2017
05 MC report - May 2018

 

thanks! 

Jen 

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus

@jenner85 ,

 

 did you notice that the dates are always in the same positions?

 

substring([filename],15,8)

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
jenner85
8 - Asteroid

@MarqueeCrew Thanks! I can't guarantee that they will always be in the same position, as this is for 10 years of files, could be missing a space somewhere or have an extra one added. 

Ben_H
11 - Bolide

Hi @jenner85,

 

I'm not the best with RegEx but I think this should work -

 

([A-Z][a-z]+[\s+|\S]\d{4})

 

Ben_H_0-1613059446187.png

 

Ben_H_1-1613059489745.png

 

 

Regards,

 

Ben

Labels
Top Solution Authors