Results 1 to 7 of 7

Thread: [RESOLVED] RegEx Us/Canada/Mexico Zip Codes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Campbell, OH USA
    Posts
    282

    Resolved [RESOLVED] RegEx Us/Canada/Mexico Zip Codes

    I have been searching the net far and wide...but I am trying to find 1 Regular Expression to validate US, Canada, and Mexico Zip Codes using one validator...does anyone have one or know where i can get one.
    Which X do you like better???
    Code:
    x     x       \      /
     x   x         \    /
      x x           \  /
       x             ><
      x x           /  \
     x   x         /    \
    x     x       /      \

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: RegEx Us/Canada/Mexico Zip Codes

    What is the format of zip-codes you want to match?
    (I don't stay in any of these countries )
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: RegEx Us/Canada/Mexico Zip Codes

    Hey,

    Have you checked out RegExLib? They have a whole library or regular expressions that you can use!

    You can find a link to the website in my signature.

    For instance:

    US Zip Code:
    http://regexlib.com/Search.aspx?k=us...=-1&m=-1&ps=20

    Canada Zip Code:
    http://regexlib.com/Search.aspx?k=ca...=-1&m=-1&ps=20

    Hope that helps!!

    Gary

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: RegEx Us/Canada/Mexico Zip Codes

    The expression for Canadian Postal Codes in the above link is incorrect. The letters D, F, I, O, Q, or U are not used.

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: RegEx Us/Canada/Mexico Zip Codes

    Hey,

    I am sure the Regular Expression can be tweaked to the OP liking, but it would give him somewhere to start.

    Gary

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Campbell, OH USA
    Posts
    282

    Re: RegEx Us/Canada/Mexico Zip Codes



    This is my issue...i can find one or the other...but i can't find a single expression that will do both...and i am terrible at trying to get them to work (it is not my strong point).
    Last edited by rrrctraptor31; Oct 23rd, 2009 at 07:46 AM. Reason: Spelling issues...lol
    Which X do you like better???
    Code:
    x     x       \      /
     x   x         \    /
      x x           \  /
       x             ><
      x x           /  \
     x   x         /    \
    x     x       /      \

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: RegEx Us/Canada/Mexico Zip Codes

    Hey,

    Why not just have two regular expressions? They are essentially doing two separate checks, so I don't see why doing two is an issue.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width