Python/Regex – How to extract date from filename using regular expression?

Assuming the date is always in the format: [MM]-[DD]-[YYYY].

re.search("([0-9]{2}\-[0-9]{2}\-[0-9]{4})", fileName)

Leave a Comment