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


Groups > comp.lang.php > #10606

Re: Zip Codes ctype? Pregmatch?

From BootNic <bootnic.bounce@gmail.com>
Newsgroups comp.lang.php
Subject Re: Zip Codes ctype? Pregmatch?
Date 2013-08-21 22:09 -0400
Organization BootNic Party Make your vote count!
Message-ID <20130821220925.01dc3738@bootnic.server> (permalink)
References <kv08v0$614$1@speranza.aioe.org> <kv0vfd$g9t$1@dont-email.me> <2791655.Q3g5IOY8jz@PointedEars.de> <kv3hd4$p9g$1@speranza.aioe.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

In article <kv3hd4$p9g$1@speranza.aioe.org>, Twayne <nobody@spamcop.net>
wrote:

[snip]

> One slight correction: the Canadian valid letters are: 
> abc e gh jklmn p rst vxy .

The second and third letters may also contain [WZ]

[url] https://maps.google.com/maps?q=B0W+1H0 [/url]

[url] https://maps.google.com/maps?q=A1W+4Z1 [/url]

The pattern you posted in: Message-ID: <kv11lq$8eb$1@speranza.aioe.org>

[url] 
https://groups.google.com/d/msg/comp.lang.php/D-OKMe-iZa4/ARnTsmDHSdIJ
[/url]

"^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])" .
"\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$"

seem to work as it is.


^(?=.{3} ?.{3})(?!.{0,}[DFIOQU]|[WZ])(?:[A-Z] ?\d){3}$

  • (?=.{3} ?.{3}) Positive lookahead

    ◦  string matches [3 charters] [optional space] [3 charters]

      ▪  charters are restricted in the rest of the expression

      ▪  remove the question mark to make the space required

  • (?!.{0,}[DFIOQU]|[WZ]) Negative lookahead

    ◦  .{0,}[DFIOQU] string may not contain ‘DFIOQU’

    ◦  [WZ] string may not start with ‘W’ or ‘Z’  

  • (?:[A-Z] ?\d){3} Basic pattern repeat 3 times

    ◦ [any letter A-Z] [optional space] [any digit 0-9]

      ▪  spaces are restricted (index 3 or none) in the Positive lookahead 

      ▪  letters are restricted in the Negative lookahead

[snip]





-- 
BootNic                                               Wed Aug 21, 2013 10:09 pm
  The human mind treats a new idea the same way the body treats a strange
  protein; it rejects it.
  *P. B. Medawar*

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