Last active
May 4, 2019 06:22
-
-
Save wamith/e6325ec7039a7acf8d3ca9e00b8403b8 to your computer and use it in GitHub Desktop.
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
/* UK Postcode Pattern | |
* < Outward Code > < Inward Code> | |
* <AREA><DISTRICT> <SECTOR><UNIT> | |
* AREA = 1 or 2 chars | |
* DISTRICT = (one or 2 digits) or (digit then letter) | |
* Space (optional) | |
* SECTOR = digit | |
* UNIT = 2 chars | |
* | |
* $postcode_regex = '/^([A-Z]{1,2})([0-9]{1,2}|[0-9][A-Z])\s?([0-9])([A-Z]{2})$/i'; | |
*/ | |
$postcode_regex='/^'. // Start of postcode | |
'([A-Z]{1,2})'. // AREA = 1 or 2 chars | |
'([0-9]{1,2}|[0-9][A-Z])'. // DISTRICT = (one or 2 digits) or (digit then letter) | |
'\s?'. // Space (optional) | |
'([0-9])'. // SECTOR = digit | |
'([A-Z]{2})'. // UNIT = 2 chars | |
'$/'; // End of Postcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment