RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\d{5}((-|\s)?\d{4})?$
Description
Single field zip code validator, useful for Web Forms. Allows user to enter 5-digit or 5-digit plus 4 zip code, with hyphen or space or NO space between last 4 digits.
Matches
92078-4705 | 920784705 | 92078 4705
Non-Matches
9027x | 902 | 92078.4705
Author Rating: The rating for this expression. MARK J KRISBURG
Source Modification of Ryan Van Aken's code
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Gud Work
Name: Nilesh
Date: 10/24/2005 12:10:25 PM
Comment:
Balle Balle


Title: Zip Code
Name: Mark Krisburg
Date: 11/14/2004 12:16:59 AM
Comment:
Web form users are unpredictable whether they will enter 5 or 9 digit zip codes, and whether they will use a hyphen or space or nothing between the first 5 digits and last 4 digits.


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials