Skip to content

Instantly share code, notes, and snippets.

@maciejniedzielski
Last active May 24, 2019 10:26
Show Gist options
  • Save maciejniedzielski/12f933e036a35d77ed3b39f7c39d3e22 to your computer and use it in GitHub Desktop.
Save maciejniedzielski/12f933e036a35d77ed3b39f7c39d3e22 to your computer and use it in GitHub Desktop.
Postal Codes regex JSON
{
"AF": {
"Country": "Afghanistan",
"Regex": "^\\d{4}$"
},
"AX": {
"Country": "Åland Islands",
"Regex": "^\\d{5}$"
},
"AL": {
"Country": "Albania",
"Regex": "^\\d{4}$"
},
"DZ": {
"Country": "Algeria",
"Regex": "^\\d{5}$"
},
"AS": {
"Country": "American Samoa",
"Regex": "^\\d{5}(-{1}\\d{4,6})$"
},
"AD": {
"Country": "Andorra",
"Regex": "^[Aa][Dd]\\d{3}$"
},
"AO": {
"Country": "Angola",
"Regex": ""
},
"AI": {
"Country": "Anguilla",
"Regex": "^[Aa][I][-][2][6][4][0]$"
},
"AG": {
"Country": "Antigua and Barbuda",
"Regex": ""
},
"AR": {
"Country": "Argentina",
"Regex": "^\\d{4}|[A-Za-z]\\d{4}[a-zA-Z]{3}$"
},
"AM": {
"Country": "Armenia",
"Regex": "^\\d{4}$"
},
"AW": {
"Country": "Aruba",
"Regex": ""
},
"AC": {
"Country": "Ascension island",
"Regex": "^[Aa][Ss][Cc][Nn]\\s{0,1}[1][Zz][Zz]$"
},
"AU": {
"Country": "Australia",
"Regex": "^\\d{4}$"
},
"AT": {
"Country": "Austria",
"Regex": "^\\d{4}$"
},
"AZ": {
"Country": "Azerbaijan",
"Regex": "^[Aa][Zz]\\d{4}$"
},
"BS": {
"Country": "Bahamas",
"Regex": ""
},
"BH": {
"Country": "Bahrain",
"Regex": "^\\d{3,4}$"
},
"BD": {
"Country": "Bangladesh",
"Regex": "^\\d{4}$"
},
"BB": {
"Country": "Barbados",
"Regex": "^[Aa][Zz]\\d{5}$"
},
"BY": {
"Country": "Belarus",
"Regex": "^\\d{6}$"
},
"BE": {
"Country": "Belgium",
"Regex": "^\\d{4}$"
},
"BZ": {
"Country": "Belize",
"Regex": ""
},
"BJ": {
"Country": "Benin",
"Regex": ""
},
"BM": {
"Country": "Bermuda",
"Regex": "^[A-Za-z]{2}\\s([A-Za-z]{2}|\\d{2})$"
},
"BT": {
"Country": "Bhutan",
"Regex": "^\\d{5}$"
},
"BO": {
"Country": "Bolivia",
"Regex": "^\\d{4}$"
},
"BQ": {
"Country": "Bonaire, Sint Eustatius and Saba",
"Regex": ""
},
"BA": {
"Country": "Bosnia and Herzegovina",
"Regex": "^\\d{5}$"
},
"BW": {
"Country": "Botswana",
"Regex": ""
},
"BR": {
"Country": "Brazil",
"Regex": "^\\d{5}-\\d{3}$"
},
"": {
"Country": "British Antarctic Territory",
"Regex": "^[Bb][Ii][Qq]{2}\\s{0,1}[1][Zz]{2}$"
},
"IO": {
"Country": "British Indian Ocean Territory",
"Regex": "^[Bb]{2}[Nn][Dd]\\s{0,1}[1][Zz]{2}$"
},
"VG": {
"Country": "British Virgin Islands",
"Regex": "^[Vv][Gg]\\d{4}$"
},
"BN": {
"Country": "Brunei",
"Regex": "^[A-Za-z]{2}\\d{4}$"
},
"BG": {
"Country": "Bulgaria",
"Regex": "^\\d{4}$"
},
"BF": {
"Country": "Burkina Faso",
"Regex": ""
},
"BI": {
"Country": "Burundi",
"Regex": ""
},
"KH": {
"Country": "Cambodia",
"Regex": "^\\d{5}$"
},
"CM": {
"Country": "Cameroon",
"Regex": ""
},
"CA": {
"Country": "Canada",
"Regex": "^(?=[^DdFfIiOoQqUu\\d\\s])[A-Za-z]\\d(?=[^DdFfIiOoQqUu\\d\\s])[A-Za-z]\\s{0,1}\\d(?=[^DdFfIiOoQqUu\\d\\s])[A-Za-z]\\d$"
},
"CV": {
"Country": "Cape Verde",
"Regex": "^\\d{4}$"
},
"KY": {
"Country": "Cayman Islands",
"Regex": "^[Kk][Yy]\\d[-\\s]{0,1}\\d{4}$"
},
"CF": {
"Country": "Central African Republic",
"Regex": ""
},
"TD": {
"Country": "Chad",
"Regex": "^\\d{5}$"
},
"CL": {
"Country": "Chile",
"Regex": "^\\d{7}\\s\\(\\d{3}-\\d{4}\\)$"
},
"CN": {
"Country": "China",
"Regex": "^\\d{6}$"
},
"CX": {
"Country": "Christmas Island",
"Regex": "^\\d{4}$"
},
"CC": {
"Country": "Cocos (Keeling) Island",
"Regex": "^\\d{4}$"
},
"CO": {
"Country": "Colombia",
"Regex": "^\\d{6}$"
},
"KM": {
"Country": "Comoros",
"Regex": ""
},
"CG": {
"Country": "Congo (Brazzaville)",
"Regex": ""
},
"CD": {
"Country": "Congo, Democratic Republic",
"Regex": "^[Cc][Dd]$"
},
"CK": {
"Country": "Cook Islands",
"Regex": ""
},
"CR": {
"Country": "Costa Rica",
"Regex": "^\\d{4,5}$"
},
"CI": {
"Country": "Côte d'Ivoire (Ivory Coast)",
"Regex": ""
},
"HR": {
"Country": "Croatia",
"Regex": "^\\d{5}$"
},
"CU": {
"Country": "Cuba",
"Regex": "^\\d{5}$"
},
"CW": {
"Country": "Curaçao",
"Regex": ""
},
"CY": {
"Country": "Cyprus",
"Regex": "^\\d{4}$"
},
"CZ": {
"Country": "Czech Republic",
"Regex": "^\\d{5}\\s\\(\\d{3}\\s\\d{2}\\)$"
},
"DK": {
"Country": "Denmark",
"Regex": "^\\d{4}$"
},
"DJ": {
"Country": "Djibouti",
"Regex": ""
},
"DM": {
"Country": "Dominica",
"Regex": ""
},
"DO": {
"Country": "Dominican Republic",
"Regex": "^\\d{5}$"
},
"TL": {
"Country": "East Timor",
"Regex": ""
},
"EC": {
"Country": "Ecuador",
"Regex": "^\\d{6}$"
},
"SV": {
"Country": "El Salvador",
"Regex": "^1101$"
},
"EG": {
"Country": "Egypt",
"Regex": "^\\d{5}$"
},
"GQ": {
"Country": "Equatorial Guinea",
"Regex": ""
},
"ER": {
"Country": "Eritrea",
"Regex": ""
},
"EE": {
"Country": "Estonia",
"Regex": "^\\d{5}$"
},
"ET": {
"Country": "Ethiopia",
"Regex": "^\\d{4}$"
},
"FK": {
"Country": "Falkland Islands",
"Regex": "^[Ff][Ii][Qq]{2}\\s{0,1}[1][Zz]{2}$"
},
"FO": {
"Country": "Faroe Islands",
"Regex": "^\\d{3}$"
},
"FJ": {
"Country": "Fiji",
"Regex": ""
},
"FI": {
"Country": "Finland",
"Regex": "^\\d{5}$"
},
"FR": {
"Country": "France",
"Regex": "^\\d{5}$"
},
"GF": {
"Country": "French Guiana",
"Regex": "^973\\d{2}$"
},
"PF": {
"Country": "French Polynesia",
"Regex": "^987\\d{2}$"
},
"TF": {
"Country": "French Southern and Antarctic Territories",
"Regex": ""
},
"GA": {
"Country": "Gabon",
"Regex": "^\\d{2}\\s[a-zA-Z-_ ]\\s\\d{2}$"
},
"GM": {
"Country": "Gambia",
"Regex": ""
},
"GE": {
"Country": "Georgia",
"Regex": "^\\d{4}$"
},
"DE": {
"Country": "Germany",
"Regex": "^(\\d{2}|\\d{4}|\\d{5})$"
},
"GH": {
"Country": "Ghana",
"Regex": ""
},
"GI": {
"Country": "Gibraltar",
"Regex": "^[Gg][Xx][1]{2}\\s{0,1}[1][Aa]{2}$"
},
"GR": {
"Country": "Greece",
"Regex": "^\\d{3}\\s{0,1}\\d{2}$"
},
"GL": {
"Country": "Greenland",
"Regex": "^\\d{4}$"
},
"GD": {
"Country": "Grenada",
"Regex": ""
},
"GP": {
"Country": "Guadeloupe",
"Regex": "^971\\d{2}$"
},
"GU": {
"Country": "Guam",
"Regex": "^\\d{5}$"
},
"GT": {
"Country": "Guatemala",
"Regex": "^\\d{5}$"
},
"GG": {
"Country": "Guernsey",
"Regex": "^[A-Za-z]{2}\\d\\s{0,1}\\d[A-Za-z]{2}$"
},
"GN": {
"Country": "Guinea",
"Regex": ""
},
"GW": {
"Country": "Guinea Bissau",
"Regex": "^\\d{4}$"
},
"GY": {
"Country": "Guyana",
"Regex": ""
},
"HT": {
"Country": "Haiti",
"Regex": "^\\d{4}$"
},
"HM": {
"Country": "Heard and McDonald Islands",
"Regex": "^\\d{4}$"
},
"HN": {
"Country": "Honduras",
"Regex": "^\\d{5}$"
},
"HK": {
"Country": "Hong Kong",
"Regex": ""
},
"HU": {
"Country": "Hungary",
"Regex": "^\\d{4}$"
},
"IS": {
"Country": "Iceland",
"Regex": "^\\d{3}$"
},
"IN": {
"Country": "India",
"Regex": "^\\d{6}$"
},
"ID": {
"Country": "Indonesia",
"Regex": "^\\d{5}$"
},
"IR": {
"Country": "Iran",
"Regex": "^\\d{5}-\\d{5}$"
},
"IQ": {
"Country": "Iraq",
"Regex": "^\\d{5}$"
},
"IE": {
"Country": "Ireland",
"Regex": ""
},
"IM": {
"Country": "Isle of Man",
"Regex": "^[Ii[Mm]\\d{1,2}\\s\\d\\[A-Z]{2}$"
},
"IL": {
"Country": "Israel",
"Regex": "^\\b\\d{5}(\\d{2})?$"
},
"IT": {
"Country": "Italy",
"Regex": "^\\d{5}$"
},
"JM": {
"Country": "Jamaica",
"Regex": "^\\d{2}$"
},
"JP": {
"Country": "Japan",
"Regex": "^\\d{7}\\s\\(\\d{3}-\\d{4}\\)$"
},
"JE": {
"Country": "Jersey",
"Regex": "^[Jj][Ee]\\d\\s{0,1}\\d[A-Za-z]{2}$"
},
"JO": {
"Country": "Jordan",
"Regex": "^\\d{5}$"
},
"KZ": {
"Country": "Kazakhstan",
"Regex": "^\\d{6}$"
},
"KE": {
"Country": "Kenya",
"Regex": "^\\d{5}$"
},
"KI": {
"Country": "Kiribati",
"Regex": ""
},
"KP": {
"Country": "Korea, North",
"Regex": ""
},
"KR": {
"Country": "South Korea",
"Regex": "^\\d{6}\\s\\(\\d{3}-\\d{3}\\)$"
},
"XK": {
"Country": "Kosovo",
"Regex": "^\\d{5}$"
},
"KW": {
"Country": "Kuwait",
"Regex": "^\\d{5}$"
},
"KG": {
"Country": "Kyrgyzstan",
"Regex": "^\\d{6}$"
},
"LV": {
"Country": "Latvia",
"Regex": "^[Ll][Vv][- ]{0,1}\\d{4}$"
},
"LA": {
"Country": "Laos",
"Regex": "^\\d{5}$"
},
"LB": {
"Country": "Lebanon",
"Regex": "^\\d{4}\\s{0,1}\\d{4}$"
},
"LS": {
"Country": "Lesotho",
"Regex": "^\\d{3}$"
},
"LR": {
"Country": "Liberia",
"Regex": "^\\d{4}$"
},
"LY": {
"Country": "Libya",
"Regex": "^\\d{5}$"
},
"LI": {
"Country": "Liechtenstein",
"Regex": "^\\d{4}$"
},
"LT": {
"Country": "Lithuania",
"Regex": "^[Ll][Tt][- ]{0,1}\\d{5}$"
},
"LU": {
"Country": "Luxembourg",
"Regex": "^\\d{4}$"
},
"MO": {
"Country": "Macau",
"Regex": ""
},
"MK": {
"Country": "Macedonia",
"Regex": "^\\d{4}$"
},
"MG": {
"Country": "Madagascar",
"Regex": "^\\d{3}$"
},
"MW": {
"Country": "Malawi",
"Regex": ""
},
"MV": {
"Country": "Maldives",
"Regex": "^\\d{4,5}$"
},
"MY": {
"Country": "Malaysia",
"Regex": "^\\d{5}$"
},
"ML": {
"Country": "Mali",
"Regex": ""
},
"MT": {
"Country": "Malta",
"Regex": "^[A-Za-z]{3}\\s{0,1}\\d{4}$"
},
"MH": {
"Country": "Marshall Islands",
"Regex": "^\\d{5}$"
},
"MR": {
"Country": "Mauritania",
"Regex": ""
},
"MU": {
"Country": "Mauritius",
"Regex": ""
},
"MQ": {
"Country": "Martinique",
"Regex": "^972\\d{2}$"
},
"YT": {
"Country": "Mayotte",
"Regex": "^976\\d{2}$"
},
"FM": {
"Country": "Micronesia",
"Regex": "^\\d{5}$"
},
"MX": {
"Country": "Mexico",
"Regex": "^\\d{5}$"
},
"MD": {
"Country": "Moldova",
"Regex": "^[Mm][Dd][- ]{0,1}\\d{4}$"
},
"MC": {
"Country": "Monaco",
"Regex": "^980\\d{2}$"
},
"MN": {
"Country": "Mongolia",
"Regex": "^\\d{5}$"
},
"ME": {
"Country": "Montenegro",
"Regex": "^\\d{5}$"
},
"MS": {
"Country": "Montserrat",
"Regex": "^[Mm][Ss][Rr]\\s{0,1}\\d{4}$"
},
"MA": {
"Country": "Morocco",
"Regex": "^\\d{5}$"
},
"MZ": {
"Country": "Mozambique",
"Regex": "^\\d{4}$"
},
"MM": {
"Country": "Myanmar",
"Regex": "^\\d{5}$"
},
"NA": {
"Country": "Namibia",
"Regex": "^\\d{5}$"
},
"NR": {
"Country": "Nauru",
"Regex": ""
},
"NP": {
"Country": "Nepal",
"Regex": "^\\d{5}$"
},
"NL": {
"Country": "Netherlands",
"Regex": "^\\d{4}\\s{0,1}[A-Za-z]{2}$"
},
"NC": {
"Country": "New Caledonia",
"Regex": "^988\\d{2}$"
},
"NZ": {
"Country": "New Zealand",
"Regex": "^\\d{4}$"
},
"NI": {
"Country": "Nicaragua",
"Regex": "^\\d{5}$"
},
"NE": {
"Country": "Niger",
"Regex": "^\\d{4}$"
},
"NG": {
"Country": "Nigeria",
"Regex": "^\\d{6}$"
},
"NU": {
"Country": "Niue",
"Regex": ""
},
"NF": {
"Country": "Norfolk Island",
"Regex": "^\\d{4}$"
},
"MP": {
"Country": "Northern Mariana Islands",
"Regex": "^\\d{5}$"
},
"NO": {
"Country": "Norway",
"Regex": "^\\d{4}$"
},
"OM": {
"Country": "Oman",
"Regex": "^\\d{3}$"
},
"PK": {
"Country": "Pakistan",
"Regex": "^\\d{5}$"
},
"PW": {
"Country": "Palau",
"Regex": "^\\d{5}$"
},
"PA": {
"Country": "Panama",
"Regex": "^\\d{6}$"
},
"PG": {
"Country": "Papua New Guinea",
"Regex": "^\\d{3}$"
},
"PY": {
"Country": "Paraguay",
"Regex": "^\\d{4}$"
},
"PE": {
"Country": "Peru",
"Regex": "^\\d{5}$"
},
"PH": {
"Country": "Philippines",
"Regex": "^\\d{4}$"
},
"PN": {
"Country": "Pitcairn Islands",
"Regex": "^[Pp][Cc][Rr][Nn]\\s{0,1}[1][Zz]{2}$"
},
"PL": {
"Country": "Poland",
"Regex": "^\\d{2}[- ]{0,1}\\d{3}$"
},
"PT": {
"Country": "Portugal",
"Regex": "^\\d{4}[- ]{0,1}\\d{3}$"
},
"PR": {
"Country": "Puerto Rico",
"Regex": "^\\d{5}$"
},
"QA": {
"Country": "Qatar",
"Regex": ""
},
"RE": {
"Country": "Réunion",
"Regex": "^974\\d{2}$"
},
"RO": {
"Country": "Romania",
"Regex": "^\\d{6}$"
},
"RU": {
"Country": "Russia",
"Regex": "^\\d{6}$"
},
"BL": {
"Country": "Saint Barthélemy",
"Regex": "^97133$"
},
"SH": {
"Country": "Tristan da Cunha",
"Regex": "^[Tt][Dd][Cc][Uu]\\s{0,1}[1][Zz]{2}$"
},
"KN": {
"Country": "Saint Kitts and Nevis",
"Regex": ""
},
"LC": {
"Country": "Saint Lucia",
"Regex": ""
},
"MF": {
"Country": "Saint Martin",
"Regex": "^97150$"
},
"PM": {
"Country": "Saint Pierre and Miquelon",
"Regex": "^97500$"
},
"VC": {
"Country": "Saint Vincent and the Grenadines",
"Regex": "^[Vv][Cc]\\d{4}$"
},
"SM": {
"Country": "San Marino",
"Regex": "^4789\\d$"
},
"ST": {
"Country": "Sao Tome and Principe",
"Regex": ""
},
"SA": {
"Country": "Saudi Arabia",
"Regex": "^\\d{5}(-{1}\\d{4})?$"
},
"SN": {
"Country": "Senegal",
"Regex": "^\\d{5}$"
},
"RS": {
"Country": "Serbia",
"Regex": "^\\d{5}$"
},
"SC": {
"Country": "Seychelles",
"Regex": ""
},
"SX": {
"Country": "Sint Maarten",
"Regex": ""
},
"SL": {
"Country": "Sierra Leone",
"Regex": ""
},
"SG": {
"Country": "Singapore",
"Regex": "^\\d{6}$"
},
"SK": {
"Country": "Slovakia",
"Regex": "^\\d{5}\\s\\(\\d{3}\\s\\d{2}\\)$"
},
"SI": {
"Country": "Slovenia",
"Regex": "^([Ss][Ii][- ]{0,1}){0,1}\\d{4}$"
},
"SB": {
"Country": "Solomon Islands",
"Regex": ""
},
"SO": {
"Country": "Somalia",
"Regex": ""
},
"ZA": {
"Country": "South Africa",
"Regex": "^\\d{4}$"
},
"GS": {
"Country": "South Georgia and the South Sandwich Islands",
"Regex": "^[Ss][Ii][Qq]{2}\\s{0,1}[1][Zz]{2}$"
},
"ES": {
"Country": "Spain",
"Regex": "^\\d{5}$"
},
"LK": {
"Country": "Sri Lanka",
"Regex": "^\\d{5}$"
},
"SD": {
"Country": "Sudan",
"Regex": "^\\d{5}$"
},
"SR": {
"Country": "Suriname",
"Regex": ""
},
"SZ": {
"Country": "Swaziland",
"Regex": "^[A-Za-z]\\d{3}$"
},
"SE": {
"Country": "Sweden",
"Regex": "^\\d{3}\\s*\\d{2}$"
},
"CH": {
"Country": "Switzerland",
"Regex": "^\\d{4}$"
},
"SJ": {
"Country": "Svalbard and Jan Mayen",
"Regex": "^\\d{4}$"
},
"SY": {
"Country": "Syria",
"Regex": ""
},
"TW": {
"Country": "Taiwan",
"Regex": "^\\d{5}$"
},
"TJ": {
"Country": "Tajikistan",
"Regex": "^\\d{6}$"
},
"TZ": {
"Country": "Tanzania",
"Regex": ""
},
"TH": {
"Country": "Thailand",
"Regex": "^\\d{5}$"
},
"TG": {
"Country": "Togo",
"Regex": ""
},
"TK": {
"Country": "Tokelau",
"Regex": ""
},
"TO": {
"Country": "Tonga",
"Regex": ""
},
"TT": {
"Country": "Trinidad and Tobago",
"Regex": "^\\d{6}$"
},
"TN": {
"Country": "Tunisia",
"Regex": "^\\d{4}$"
},
"TR": {
"Country": "Turkey",
"Regex": "^\\d{5}$"
},
"TM": {
"Country": "Turkmenistan",
"Regex": "^\\d{6}$"
},
"TC": {
"Country": "Turks and Caicos Islands",
"Regex": "^[Tt][Kk][Cc][Aa]\\s{0,1}[1][Zz]{2}$"
},
"TV": {
"Country": "Tuvalu",
"Regex": ""
},
"UG": {
"Country": "Uganda",
"Regex": ""
},
"UA": {
"Country": "Ukraine",
"Regex": "^\\d{5}$"
},
"AE": {
"Country": "United Arab Emirates",
"Regex": ""
},
"GB": {
"Country": "United Kingdom",
"Regex": "^[A-Z]{1,2}[0-9R][0-9A-Z]?\\s*[0-9][A-Z-[CIKMOV]]{2}"
},
"US": {
"Country": "United States",
"Regex": "^\\b\\d{5}\\b(?:[- ]{1}\\d{4})?$"
},
"UY": {
"Country": "Uruguay",
"Regex": "^\\d{5}$"
},
"VI": {
"Country": "U.S. Virgin Islands",
"Regex": "^\\d{5}$"
},
"UZ": {
"Country": "Uzbekistan",
"Regex": "^\\d{3} \\d{3}$"
},
"VU": {
"Country": "Vanuatu",
"Regex": ""
},
"VA": {
"Country": "Vatican",
"Regex": "^120$"
},
"VE": {
"Country": "Venezuela",
"Regex": "^\\d{4}(\\s[a-zA-Z]{1})?$"
},
"VN": {
"Country": "Vietnam",
"Regex": "^\\d{6}$"
},
"WF": {
"Country": "Wallis and Futuna",
"Regex": "^986\\d{2}$"
},
"YE": {
"Country": "Yemen",
"Regex": ""
},
"ZM": {
"Country": "Zambia",
"Regex": "^\\d{5}$"
},
"ZW": {
"Country": "Zimbabwe",
"Regex": ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment