Alteryx Designer Desktop Discussions

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

RegEx parse Month from FileName

Ragini
7 - Meteor

Hi RegEx Vets,

I'm not super familiar with RegEx so would really appreciate your help. I'm trying to extract Year & Month from a FileName. I was able to get the formula for Year but was unable to manipulate it to get the Month.  

 

"S:\SSP-SS\GeneralLedger\Trial Balance\2019\Final Versions of TB\11. Nov 2019 FERC Trial Balance.xlsx|||`FERC Trial Balance by CC_PC_Seg$`" is the FileName.

 

I was able to extract Year using Formula: REGEX_Replace([FileName],"S:\\SSP-SS\\GeneralLedger\\Trial Balance\\([^\\]+)\\.*","$1") in the Formula Tool.

 

Im trying to extract the month (i.e. 11 in the above FileName using this formula but it does not work.

REGEX_Replace([FileName],"S:\\SSP-SS\\GeneralLedger\\Trial Balance\\2019\Final Versions of TB\\([^\\]+)\\.*","$1")

 

What am I doing wrong and what is the correct syntax? Also what would be the syntax if I wanted to extract month name i.e  "Nov" ? The filepath changes dynamically to reference diff months so I do not want to hardcode the formula expression "11" or "Nov"

 

Thanks so much for your assistance!

7 REPLIES 7

Hi @Ragini 

 

Please check the below. This will work if directory will remain the same as well as the pattern when it comes to month and year

 

christine_assaad_1-1608667744290.png

 

 

Ragini
7 - Meteor

@christine_assaad  thank you for your solution , however I'm not getting it to work. It is a bit difficult to see from the screenshot since the parenthesis look alike and small. This is what I input based on typing out the formula in your screenshot . Does the formula look correct

?

 

"S:\\SSP-SS\\GeneralLedger\\Trial Balance\\2019\\Final Versions of TB\\(\d+).\s(\w{3})\s(\d{4})."

Hi @Ragini 

 

This is the syntax I used

 

S\:\\SSP-SS\\GeneralLedger\\Trial Balance\\2019\\Final Versions of TB\\(\d+).\s(\w{3})\s(\d{4}).*

Ragini
7 - Meteor

@christine_assaad  thank you so much!! That works!

Qiu
20 - Arcturus
20 - Arcturus

@Ragini 

How about a simpler one?

1223-Ragini.PNG

Ragini
7 - Meteor

@Qiu  even better thank you!!

Qiu
20 - Arcturus
20 - Arcturus

@Ragini 
Thank you for the accept mark also.

Labels