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}-\d{4}|\d{5})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$
Description
This is a modification of the zip code regular expression submitted by Steven Smith (ssmith@aspalliance.com) It no longer matches 78754-12aA
Matches
78754 | 78754-1234 | G3H 6A3
Non-Matches
78754-12aA | 7875A | g3h6a3
Author Rating: Not yet rated. Khoi Pham
Source
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: Zip/Postal Code RegEx
Name: Benny Hill
Date: 5/14/2004 11:54:25 AM
Comment:
This does not work for me in PHP either.


Title: Zip/Postal Code RegEx
Name: W. D.
Date: 1/3/2004 7:38:47 PM
Comment:
Hmmm. Doesn't seem to work for me in PHP: If (eregi("^(\d{5}-\d{4}|\d{5})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$", $ThisZip)) {Return "OK";} // It's OK Else {Return "Bad Format for US or CA Zip/Postal Code";} // It's bad


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