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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find US & Canadian Zip Code for Input
Expression
^(\d{5})$|^([a-zA-Z]\d[a-zA-Z]( )?\d[a-zA-Z]\d)$
Description
Created for input validation of major part of zip code. Normal Canadian entry has an optional space between the first group of three and the second group. Original pattern taken from Steven Smith and modified for our entries.
Matches
12345|A6A 6A6|A6A6A6
Non-Matches
aaaaa|6A6A6A
Author Rating: Not yet rated. Jeff Finley
Source Original by Steven Smith
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: need to delimit space
Name: lonepie
Date: 2/12/2008 9:48:06 AM
Comment:
In some cases, you may have to replace the ( )? with (\ )? to detect the space


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