note 80654 added to function.ereg

From: Date: Mon, 28 Jan 2008 04:48:20 +0000
Subject: note 80654 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-135447@lists.php.net to get a copy of this message
This is a date regexp that I made to allow different combinations of month, day, and year. it's rather long but it works. (^([0-3]{0,1})([1-9]{1,1})([\-]{1,1})(([1]{1,1})([0-2]{1,1})| ([0]{0,1})([1-9]{1,1}))([\-]{1,1})([1-2]{1,1})(\d{3})$)| (^(([1]{1,1})([0-2]{1,1})|([0]{0,1})([1-9]{1,1}))([\-]{1,1}) ([0-3]{0,1})([1-9]{1,1})([\-]{1,1})([1-2]{1,1})(\d{3})$)| (^([1-2]{1,1})(\d{3})([\-]{1,1})(([1]{1,1})([0-2]{1,1})| ([0]{0,1})([1-9]{1,1}))([\-]{1,1})([0-3]{0,1})([1-9]{1,1})$) yyyy-mm-dd, mm-dd-yyyy, dd-mm-yyyy 2007-02-05 12-25-2007 25-02-2007 2-5-2007 25-2-2007 2007-9-23 09-06-2007 09-23-2007 The above will check valid Anything not in one of the combinations of dd,mm,yyyy formats above will fail. these will also fail 2007-32-12 13-22-2007 0-1-2007 1-0-2007 Any sugestions on making it smaller and more efficients would be appreciated. ---- Server IP: 64.71.164.2 Probable Submitter: 68.103.12.249 ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- https://master.php.net/note/edit/80654 Del: integrated -- https://master.php.net/note/delete/80654/integrated Del: useless -- https://master.php.net/note/delete/80654/useless Del: bad code -- https://master.php.net/note/delete/80654/bad+code Del: spam -- https://master.php.net/note/delete/80654/spam Del: non-english -- https://master.php.net/note/delete/80654/non-english Del: in docs -- https://master.php.net/note/delete/80654/in+docs Del: other reasons-- https://master.php.net/note/delete/80654 Reject -- https://master.php.net/note/reject/80654 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135447) next »