Thursday, June 23, 2011

Regex For Matching File Names with Date

Here is some example of file name matching regex:

File Format:

FileName-dd-mm-yyyy.EXT:
^(FileName)-([1-9]|0[1-9]|[12][0-9]|3[01])-([1-9]|0[1-9]|1[012])-(19[0-9][0-9]|20[0-9][0-9])\.EXT$

See here for a good reference: http://msdn.microsoft.com/en-us/library/az24scfc.aspx
Also you can test your expression here: http://www.regextester.com/

No comments:

Post a Comment