Friday, April 03, 2009

Regular Expression Date Detector

The regular expression

[01]?[0-9]/[1-3]?[0-9]/(20)?0[0-9]

finds dates since 2000 in mm/dd/yyyy format. Granted, it also finds some invalid dates (like 00/0/2000) but it gets the job done 99% of the time if your just trying to find dates within a document, rather than validate dates.

No comments: