Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10603
| Message-ID | <9308699.c6ZVUcr4Hi@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-08-21 15:06 +0200 |
| Subject | Re: Zip Codes ctype? Pregmatch? |
| Newsgroups | comp.lang.php |
| References | <kv08v0$614$1@speranza.aioe.org> <kv0vfd$g9t$1@dont-email.me> <2791655.Q3g5IOY8jz@PointedEars.de> <7964092.hUFTFP9gJ2@PointedEars.de> |
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". […]
>>>
>>> US Zip code:
>>> [0-9]{5}(-{0,1}[0-9]{4}){0,1}
>> ^^^^^ ^^^^^^^^^^ ^^^^^
>> […]
>> However, the specification above says that “00000” and “99999” are _not_
>> valid U.S. ZIP codes, so to be exact you cannot just use either
>> “[0-9]{5}” or “\d{5}”; but you would have to use, for example, a
>> zero-width negative lookahead:
>>
>> $possibleZips = array('00000', '00001', '99998', '99999');
$possibleZips = array('00000', '00001', '99998', '90909', '99999');
>> foreach ($possibleZips as $possibleZip)
>> {
>> preg_match('^(?![09]{5})\\d{5}(?:-?\\d{4})?$', $possibleZip,
>
> 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);
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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