SZC’s Agglomeration

{an agglomeration of laconic notes in relation to anything that sparks my interest}

date validation regular expression

Posted by Stefan Camilleri on {2008.July.30}

/** Here is some handy regex to validate a date using british locale (dd/mm/yy or dd/mm/yyyy) */

Note, this allows / \ . or – as delimiters {

^(?:(?:0?[1-9])|(?:[1-2]\d)|(?:3[0-1]))[-.\\/](?:(?:0?[1-9])|(?:1[0-2]))[-.\\/](?:(?:\d{3}[1-9])|(?:\d{2}[1-9]\d)|(?:\d[1-9]\d{2})|(?:[1-9]\d{3})|(?:\d{2}))$

}

p.s. this regex has now been superseded with an improved version here

2 Responses to “date validation regular expression”

  1. Caxaria said

    You always remind me of him, with your regex love :D

  2. Ooooh more RSS :D :D:D:D

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>