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 #182653 is a reply to message #182652] Thu, 22 August 2013 02:09 Go to previous messageGo to previous message
BootNic is currently offline  BootNic
Messages: 10
Registered: November 2010
Karma:
Junior Member
In article <kv3hd4$p9g$1(at)speranza(dot)aioe(dot)org>, Twayne <nobody(at)spamcop(dot)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]

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

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

The pattern you posted in: Message-ID: <kv11lq$8eb$1(at)speranza(dot)aioe(dot)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*
[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: Fri Sep 20 08:55:06 GMT 2024

Total time taken to generate the page: 0.04893 seconds