note 71607 deleted from function.preg-match by nlopess

From: Date: Thu, 07 Dec 2006 18:17:35 +0000
Subject: note 71607 deleted from function.preg-match by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-120404@lists.php.net to get a copy of this message
Note Submitter: fred dot adm at terra dot com dot br ---- This regular expression will match any valid date. ;) It also checks for leap years. Format: DD/MM/YYYY function foo($s) { $e = "(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)"; $e .= "([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)"; $e .= "([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))"; $e .= "|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])"; $e .= "([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|"; $e .= "((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])"; $e .= "([0-9][0-9][13579][26])))"; if(preg_match($e, $s)) return true; else return false; }

« previous php.notes (#120404) next »