Skip to content

Instantly share code, notes, and snippets.

View wyattschwanbeck's full-sized avatar

Wyatt Schwanbeck wyattschwanbeck

View GitHub Profile
@wyattschwanbeck
wyattschwanbeck / FileAndDateMatch.REGEX
Last active May 25, 2022 22:31
Regex for windows file parsing, matching, and validation.
//https://www.codeproject.com/Tips/216238/Regular-Expression-to-Validate-File-Path-and-Exten?msg=5202231#xx5202231xx
//Credit Bryian Tan 2012
^(?:[\w]\:|\\)(\\[a-z_\-\s0-9\.]+)+\.(txt|gif|pdf|doc|docx|xls|xlsx)$
//Adapted and expanded variations
//Added capital letters
(?:[\w]\:|\\)(\\[A-Za-z_\-\s0-9\.]+)+\.(txt|gif|pdf|doc|docx|xls|xlsx)
//Adapted to forward slashes and added capital letters to match
(?:[\w]\:|\/)(\/[A-Za-z_\-\s0-9\.]+)+\.(txt|gif|pdf|doc|docx|xls|xlsx)