note 18745 modified in function.ereg by sander
| From: | sander@php.net | Date: | Sun, 12 May 2002 15:53:07 +0000 |
| Subject: | note 18745 modified in function.ereg by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-30539@lists.php.net to get a copy of this message | ||
The postcode example listed here isn't correct - it won't correctly detect Inner London
postcodes (and others?) with an extra letter, eg:
EC1M 3AA
I've also ammended it so that the space is optional:
if(eregi('^[A-Z]{1,2}[0-9]{1,2}[A-Z]? ?[0-9][A-Z]{2}$',$postcode)
{
print "You have a valid postcode!";
}
--was--
The postcode example listed here isn't correct - it won't correctly detect Inner London
postcodes (and others?) with an extra letter, eg:
EC1M 3AA
I've also ammended it so that the space is optional:
if(eregi('^[A-Z]{1,2}[1-9]{1,2}[A-Z]? ?[1-9][A-Z]{2}$',$postcode))
{
print "You have a valid postcode!";
}
http://www.php.net/manual/en/function.ereg.php