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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^([A-Z]{1,2}[0-9]{1,2}|[A-Z]{3}|[A-Z]{1,2}[0-9][A-Z])( |-)[0-9][A-Z]{2}
Description
Checks whether the string specified is in the same format as the UK postcode format defined on: http://www.magma.ca/~djcl/postcd.txt It allows: A = Letter N = Number AN NAA, ANA NAA, ANN NAA, AAN NAA, AAA NAA (rare), AANN NAA, AANA NAA It gives the option to have the two parts of the uk postcode to be separated by a space or a hyphen. (restriction is set to all-capitals)
Matches
AA11 1AA | AA1A 1AA | A11-1AA
Non-Matches
111 AAA | 1AAA 1AA | A1AA 1AA
Author Rating: Not yet rated. Henk de Vries
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: I required upper case letters
Name: Henk
Date: 2/16/2006 8:34:46 AM
Comment:
But I guess you're right, I don't need to bother my client with this. If I want it upper case, i could just MAKE it uuper case.


Title: MR
Name: Developer
Date: 8/24/2005 7:07:35 AM
Comment:
case-insensitive version: ^([A-Za-z]{1,2}[0-9]{1,2}|[A-Za-z]{3}|[A-Za-z]{1,2}[0-9][A-Za-z])( |-)[0-9][A-Za-z]{2}


Title: Mr
Name: Tester
Date: 5/3/2005 9:35:11 AM
Comment:
This is case sensitive. Not nice. Needs to be case insensitive.


Title: Not very good
Name: Howard
Date: 4/16/2005 6:45:42 AM
Comment:
A very basic validator, about 60% effective (it permitted 627 of 1423 invalid postcodes).


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