note 45205 added to function.preg-match
| From: | user at NOSPAM dot example dot com | Date: | Sun, 29 Aug 2004 19:11:32 +0000 |
| Subject: | note 45205 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75586@lists.php.net to get a copy of this message | ||
This little regex will validate a US Zip code in either ZIP or ZIP+4 format... Took me some time to
get it, wanted to save someone else the trouble.
<?
preg_match("/^[2-9][0-9]{4}([-]{1}[0-9]{4})?$/",$string))
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45205
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45205&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45205&report=yes
Search -- http://master.php.net/manage/user-notes.php