Skip to content

Instantly share code, notes, and snippets.

@sanchojaf
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save sanchojaf/d5f17f021c6e5143fad4 to your computer and use it in GitHub Desktop.

Select an option

Save sanchojaf/d5f17f021c6e5143fad4 to your computer and use it in GitHub Desktop.
This expression validates dates in the US m/d/y format from 1/1/1600 - 12/31/9999.
Title: m/d/y Date
Expression:
^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[13-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
Description:
This expression validates dates in the US m/d/y format from 1/1/1600 - 12/31/9999.
Matches:
01.1.02 | 11-30-2001 | 2/29/2000
Non-Matches:
02/29/01 | 13/01/2002 | 11/00/02
Source:
http://www.regexlib.com/(X(1)A(sRsR8VbiGZtzIHXtkyUXVkNTa0mSP9dCQMtddYzPj1auqKuJKczWUq3lNc8igxuLIlZiEW12rTPT8Zxin5Uz--yYecA1qJErioNl-0w4oDlSakFreADXVx_GjzwO9juzrX4Z8fsBwUPQe1jWmNiqwAh4bmqchcOksU5pVFQBqHRAMp3UvfEKQZmjkivFhOLN0))/REDetails.aspx?regexp_id=113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment