This code below is suppose to do all this for me, but it's not matching as I'd hoped. I get results like this:
21832-1234 MATCHES. 00000-0000 MATCHES. 00000 MATCHES. 1234 doesn't match. ABCDEF doesn't match. ABC doesn't match.
I'd appreciate any help. Thanks, jason
<?php
$regex1 = "/^(\?(^00000(|-0000))|(\d{5}(|-\d{4})))$/";
$zips = array("21243","21832-1234","00000-0000","00000","1234","ABCDEF","ABC");
foreach ($zips as $zip) { if (preg_match($regex1,$zip)) { echo "$zip MATCHES.<br>"; } else { echo "$zip doesn't match.<br>"; } }
?>
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php