Re: Filters and sanitizing a regexp
| From: | Richard Heyes | Date: | Thu, 25 Sep 2008 19:27:45 +0000 |
| Subject: | Re: Filters and sanitizing a regexp | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280936@lists.php.net to get a copy of this message | ||
> ...
Hi,
Had to have a play with this. Here's my (somewhat stricter) regex:
preg_match('/((?:[0-3]?[0-9])?\d)-([0-1]?\d)-20\d\d/', '31-12-2000', $matches);
if (!empty($matches[1]) AND $matches[1] > 31) $matches = array();
if (!empty($matches[2]) AND $matches[2] > 12) $matches = array();
You could probably do the checks for the day and month within the
regex, but it's late :-)
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.phpguru.org/RGraph