FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Zip Codes ctype? Pregmatch?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Zip Codes ctype? Pregmatch? [message #182657 is a reply to message #182650] Sat, 24 August 2013 10:22 Go to previous messageGo to previous message
Curtis Dyer is currently offline  Curtis Dyer
Messages: 34
Registered: January 2011
Karma:
Member
Thomas 'PointedEars' Lahn <PointedEars(at)web(dot)de> wrote:

> Thomas 'PointedEars' Lahn wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Norman Peelman wrote:
>>>> On 08/20/2013 01:27 PM, Twayne wrote:
>>>> > I'm attempting to check for US and Canadian zip codes
>>>> > (postal codes). The US is easy; mostly just be sure it's
>>>> > five numerics and except "00000" and "99999". […]

<snip>

>> Replace this line with
>>
>> preg_match('/^(?![09]{5})\\d{5}(?:-?\\d{4})?$/',
>> $possibleZip,
>>
>> (add the delimiter).
>
> Which is still not correct, because '/[09]{5}/' matches "90909",
> which is thus designated not valid. ISTM that alternation is
> required here:
>
> preg_match('/^(?!0{5}|9{5})\\d{5}(?:-?\\d{4})?$/',
> $possibleZip);

Perhaps you might also keep invalid postal codes in an array to look
up before utilizing the regular expression.

<snip>

--
Curtis Dyer
<?$x='<?$x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Where's the error?
Next Topic: Xml Loading special Characters
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 11:36:58 GMT 2024

Total time taken to generate the page: 0.03283 seconds