note 65983 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:29:44 +0000
Subject: note 65983 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127623@lists.php.net to get a copy of this message
Note Submitter: axima at prameasolutions dot com ---- 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

« previous php.notes (#127623) next »