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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^[0-9]{5}([\s-]{1}[0-9]{4})?$
Description
My first Expression. This will match US postal codes (zip codes) using simple 5 digit format with optional 4 digit extention seperated by a space or hyphen. Will not accept letters. example: 12345 or 12345-1234 or 12345 1234.
Matches
12345-1234 | 12345 | 12345 1234
Non-Matches
123451234 | 12345 a345 | a2345-1234
Author Rating: Not yet rated. Ed Stafford
Source Edward Stafford - www.pixelengineers.com
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: Does not error when all zeros are entered.
Name: Dawn
Date: 3/7/2018 2:25:47 PM
Comment:
This does not error if all zeros are entered which is an invalid US Zip Code


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