not exactly answering the question, but I had once the mission of validating postal codes
I build up the following regexes for that purpose; hope that helps.
as some stated before me, there is no way to validate EVERY address in a given country, let alone on the planet! it will have to be a general text field, maybe just check for characters you don't want:"?<>=;@$%^*!" and sanitize the input not to get SQL injected.
in my application, the postal code was tested depending of the country field but if you know you will test only a selected few you can put some together
eg:US/UK = /^([\d]{5}(-[\d]{4})?)|([A-Z]?[A-Z][0-9][A-Z0-9]?\s[0-9][A-Z]{2})/
Afghanistan,Angola,Belize,Benin,Hong Kong,Ireland, Macau
no Postal Code
Argentina
^[A-Z][0-9]{4}[A-Z]{3}$
Canada
^(?!.*[DFIOQU].*)([A-Z][0-9]){3}$
US
^[\d]{5}(-[\d]{4})?$
UK
^[A-Z]?[A-Z][0-9][A-Z0-9]?\s[0-9][A-Z]{2}$
Latvia
^LV[-\s]?[\d]{4}$
Hungary,Denmark,Cyprus,Georgia,Bangladesh,Austria,Armenia,Australia,Albania,Belgium,Bulgaria,Cape Verde,Philippines,Paraguay
Norway,New Zealand,Liechtenstein,Luxembourg,South Africa,Tunisia,Switzerland
^[\d]{4}$
Netherlands
^[\d]{4}\s[A-Z]{2}$
Portugal
^[\d]{4}[\s-][\d]{3}$
Israel,Iraq,Indonesia,Greece,Germany,Guam,Croatia,Costa Rica,Estonia,Egypt,France,Finland,American Samoa,Algeria
Brazil,Bosnia and Herzegovina,Cambodia,Palau,Morocco,Montenegro,Northern Mariana Islands,Lithuania,Italy,Malaysia
Mexico,Marshall Islands,Micronesia,Serbia,Puerto Rico,San Marino,Taiwan,Thailand,Spain,Sri Lanka,Turkey,Ukraine,U.S. Virgin Islands,Vatican
^[\d]{5}$
Poland
^[\d]{2}[\s-]?[\d]{3}$
Czech Republic, Slovakia, Sweden
^[\d]{3}[\s-]?[\d]{2}$
Iran
^[\d]{5}[\s-][\d]{5}$
China,Colombia,Belarus,Panama,Pakistan,Nigeria,Kazakhstan,Singapore,Romania,Russia
^[\d]{6}$