Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10611

Re: Zip Codes ctype? Pregmatch?

Message-ID <1622651.Cd0mxx89pG@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-08-24 12:52 +0200
Subject Re: Zip Codes ctype? Pregmatch?
Newsgroups comp.lang.php
References (1 earlier) <kv0vfd$g9t$1@dont-email.me> <2791655.Q3g5IOY8jz@PointedEars.de> <7964092.hUFTFP9gJ2@PointedEars.de> <9308699.c6ZVUcr4Hi@PointedEars.de> <kva1hr$rc0$1@dont-email.me>

Show all headers | View raw


Curtis Dyer wrote:

> Thomas 'PointedEars' Lahn <PointedEars@web.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.

I did that exactly where you snipped.


PointedEars
-- 
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 13:27 -0400
  Re: Zip Codes  ctype? Pregmatch? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-20 11:59 -0600
    Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 15:01 -0400
  Re: Zip Codes  ctype? Pregmatch? Robert Heller <heller@deepsoft.com> - 2013-08-20 13:08 -0500
    Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 15:03 -0400
      Re: Zip Codes  ctype? Pregmatch? Robert Heller <heller@deepsoft.com> - 2013-08-20 14:36 -0500
        Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 20:17 -0400
  Re: Zip Codes  ctype? Pregmatch? RESOLVED Twayne <nobody@spamcop.net> - 2013-08-20 15:06 -0400
    Re: Zip Codes  ctype? Pregmatch? RESOLVED Norman Peelman <npeelman@cfl.rr.com> - 2013-08-20 19:53 -0400
      Re: Zip Codes  ctype? Pregmatch? RESOLVED Twayne <nobody@spamcop.net> - 2013-08-20 20:29 -0400
        Re: Zip Codes  ctype? Pregmatch? RESOLVED Moon Elf <moonelf@moonelfsystem.net> - 2013-12-16 10:02 +0000
          Re: Zip Codes  ctype? Pregmatch? RESOLVED Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-16 12:27 +0000
  Re: Zip Codes  ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-20 19:52 -0400
    Re: Zip Codes  ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 14:53 +0200
      Re: Zip Codes  ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 14:58 +0200
        Re: Zip Codes  ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 15:06 +0200
          Re: Zip Codes  ctype? Pregmatch? Curtis Dyer <dyer85@gmail.com> - 2013-08-24 10:22 +0000
            Re: Zip Codes  ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-24 12:52 +0200
            Re: Zip Codes  ctype? Pregmatch? Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-08-25 14:31 +0000
              Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-25 13:21 -0400
            Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-25 13:17 -0400
      Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-21 19:10 -0400
        Re: Zip Codes  ctype? Pregmatch? BootNic <bootnic.bounce@gmail.com> - 2013-08-21 22:09 -0400
          Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-22 18:22 -0400
  Re: Zip Codes  ctype? Pregmatch? Jeff North <jnorthau@yahoo.com.au> - 2013-08-21 21:25 +1000
    Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-21 18:53 -0400
      Re: Zip Codes  ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-21 22:46 -0400
  Re: Zip Codes  ctype? Pregmatch? gordonb.qnlcm@burditt.org (Gordon Burditt) - 2013-08-31 01:17 -0500
    Re: Zip Codes  ctype? Pregmatch? Fiver <numeralfive@gmail.com> - 2013-08-31 16:40 +0200
      Re: Zip Codes  ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-31 11:56 -0400
        Re: Zip Codes  ctype? Pregmatch? Welsh Vanner <welshvanners@welsh-vanners.co.uk> - 2013-08-31 20:23 +0100
        Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-31 20:21 -0400
      Re: Zip Codes  ctype? Pregmatch? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-31 09:56 -0600
    Re: Zip Codes  ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-31 20:07 -0400

csiph-web