note 65983 added to function.preg-match
| From: | aximaatprameasolutionsdotcom at osu1 dot php dot net | Date: | Thu, 11 May 2006 11:34:43 +0000 |
| Subject: | note 65983 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111122@lists.php.net to get a copy of this message | ||
function to validate and extract date parts from the string in following formats:
dd-mm-yyyy or dd/mm/yyyy or dd mm yyyy
d-m-yyyy and so on
actually delimiter is what ever exept a number
funtion get_correct_date($input = ''){
//clean up the input
$input = trim($input);
//matching pattern
$pattern = '/^([1-9]|0[1-9]|[12][1-9]|3[01])\D([1-9]|0[1-9]|1[012])\D
(19[0-9][0-9]|20[0-9][0-9])$/';
//check the input
preg_match(input ,$pattern, $parts);
return $parts;
}
function will return empty array on failure or
parts of the date as array(dd,mm,yyyy);
note: remove empty space from pattern if you copy it from here
----
Server IP: 80.81.171.181
Probable Submitter: 194.251.240.117 (proxied: 1.0 hud8-hki:80 (DataReactor/4.0.7p3))
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/note/edit/65983
Del: integrated -- http://master.php.net/note/delete/65983/integrated
Del: useless -- http://master.php.net/note/delete/65983/useless
Del: bad code -- http://master.php.net/note/delete/65983/bad+code
Del: spam -- http://master.php.net/note/delete/65983/spam
Del: non-english -- http://master.php.net/note/delete/65983/non-english
Del: in docs -- http://master.php.net/note/delete/65983/in+docs
Del: other reasons-- http://master.php.net/note/delete/65983
Reject -- http://master.php.net/note/reject/65983
Search -- http://master.php.net/manage/user-notes.php