Results 1 to 4 of 4

Thread: How to check regex for Zip Code

  1. #1
    Join Date
    Feb 2009
    Posts
    62

    How to check regex for Zip Code

    Can any tell how do I match my Zip code with the regular expression, I stay in U.S with the other countries this would make me nuke and i can't go further, I have also tried writing in expression but when i tried to execute it does not work.

  2. #2
    Join Date
    Jan 2009
    Posts
    150

    Re: How to check regex for Zip Code

    I have tried with above three expressions. The regular expression doesn't need a lot of explanation. ^\d{5} says that the regular expression must start ("^") with exactly five ("{5}") digits ("\d"). ([\-]\d{4})? Last expression i.e.Matches US or Canadian zip codes in above formats is not validating if I enter 12345 e123 or 12345 123r. JavaScript regular expression to validate zip code. Let me first show you the JS code.

  3. #3
    Join Date
    Feb 2009
    Posts
    62

    Re: How to check regex for Zip Code

    Some of the addresses are missing a space between the streetname and the ZIP code. I put the code and one of the user complained that it wont work, The user's canada Zip code is M5R 1GR that means the pattern is changed. Now in this Zip code its ANA NAA.

  4. #4
    Join Date
    Feb 2008
    Posts
    180

    Re: How to check regex for Zip Code

    For this we are going to make program named Matching_Zipcode.java. The steps involved in program Matching_Zipcode.java are described below:-

    To Check Indian Zip codes use

    String zipCode = "\\d{5}(-\\d{4})?":-This is the regular expression use to match with Zip code.

    Imports System.Text.RegularExpressions

    Function IsValidZip(ByVal sZipCode As String)

    Return Regex.IsMatch(sZipCode, "^\d{6}$")

    End Function

    A valid zip code can either have 5 digits or 5 digits followed by an hyphen(-) and ends with four digits.

Similar Threads

  1. Replies: 2
    Last Post: 01-12-2010, 09:33 PM
  2. Put check mark on the item ToolStripDropDownItem using the code
    By Laavanya in forum Software Development
    Replies: 3
    Last Post: 25-10-2010, 11:42 AM
  3. Windows 7 Blue Screen, Bug Check Code : 0x000000e4
    By Jasonholt in forum Networking & Security
    Replies: 4
    Last Post: 20-04-2010, 12:49 PM
  4. Check if the character is a Regex
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 04:29 AM
  5. C++ code to check or search if a file exists or not?
    By RadhaV in forum Software Development
    Replies: 4
    Last Post: 17-02-2009, 11:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,053,354.48875 seconds with 16 queries