Created
January 29, 2013 10:03
-
-
Save benshimmin/4663176 to your computer and use it in GitHub Desktop.
Simple (albeit slightly overly permissive) UK postcode regular expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var regex = /^[A-Z]{1,2}[0-9]{1,2}[A-Z]? ?[0-9][A-Z]{2}$/i; | |
/** | |
* NB. This is case-insensitive and doesn't care about the whitespace. | |
* | |
* Matches these formats: | |
* | |
* AA9A 9AA | |
* A9A 9AA | |
* A9 9AA | |
* A99 9AA | |
* AA9 9AA | |
* AA99 9AA | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment