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!
Solved! Go to Solution.
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 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}).*
@christine_assaad thank you so much!! That works!
@Qiu even better thank you!!
@Ragini
Thank you for the accept mark also.