In Sheet1 I have the following table of zip code formats:
[TABLE="width: 259"]
<tbody>[TR]
[TD]ISO[/TD]
[TD]Country[/TD]
[TD]Format[/TD]
[/TR]
[TR]
[TD]AU[/TD]
[TD]Australia[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]AT[/TD]
[TD]Austria[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]BE[/TD]
[TD]Belgium[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]BR[/TD]
[TD]Brazil[/TD]
[TD]99999[-999][/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]Canada[/TD]
[TD]A9A 9A9[/TD]
[/TR]
[TR]
[TD]DK[/TD]
[TD]Denmark[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]FI[/TD]
[TD]Finland[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]FR[/TD]
[TD]France[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]DE[/TD]
[TD]Germany[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]HU[/TD]
[TD]Hungary[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]IE[/TD]
[TD]Ireland[/TD]
[TD]A9A AAAA[/TD]
[/TR]
[TR]
[TD]IL[/TD]
[TD]Israel[/TD]
[TD]99999 99[/TD]
[/TR]
[TR]
[TD]IT[/TD]
[TD]Italy[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]JP[/TD]
[TD]Japan[/TD]
[TD]999-9999[/TD]
[/TR]
[TR]
[TD]LU[/TD]
[TD]Luxembourg[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]MY[/TD]
[TD]Malaysia[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]MX[/TD]
[TD]Mexico[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]NL[/TD]
[TD]Netherlands[/TD]
[TD]9999 AA[/TD]
[/TR]
[TR]
[TD]NZ[/TD]
[TD]New Zealand[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]Norway[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]PL[/TD]
[TD]Poland[/TD]
[TD]99-999[/TD]
[/TR]
[TR]
[TD]PT[/TD]
[TD]Portugal[/TD]
[TD]9999-999[/TD]
[/TR]
[TR]
[TD]RU[/TD]
[TD]Russia[/TD]
[TD]999999[/TD]
[/TR]
[TR]
[TD]SA[/TD]
[TD]Saudi Arabia[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]SG[/TD]
[TD]Singapore[/TD]
[TD]999999[/TD]
[/TR]
[TR]
[TD]KR[/TD]
[TD]South Korea[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]SE[/TD]
[TD]Sweden[/TD]
[TD]999 99[/TD]
[/TR]
[TR]
[TD]CH[/TD]
[TD]Switzerland[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]TR[/TD]
[TD]Turkey[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]UA[/TD]
[TD]Ukraine[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]United Kingdom[/TD]
[TD]AA9[9] 9AA[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]United States[/TD]
[TD]99999[-9999][/TD]
[/TR]
</tbody>[/TABLE]
A represents alphabet
9 represents number
[ ] represents optional
In Sheet2 I have the following input zip codes and the expected output:
[TABLE="width: 300"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Zip (Input)[/TD]
[TD]Zip (Output)[/TD]
[/TR]
[TR]
[TD]NL[/TD]
[TD]1613 LC[/TD]
[TD]1613LC[/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]J7J1C1[/TD]
[TD]J7J 1C1[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]CT179PA[/TD]
[TD]CT17 9PA[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]CM29BE[/TD]
[TD]CM2 9BE[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]74112[/TD]
[TD]74112[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]6354[/TD]
[TD]06354[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]207354607[/TD]
[TD]20735-4607[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]20735 4607[/TD]
[TD]20735-4607[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]20735-4607[/TD]
[TD]20735-4607[/TD]
[/TR]
</tbody>[/TABLE]
How do I convert the input string to a valid zip code based on the corresponding format?
[TABLE="width: 259"]
<tbody>[TR]
[TD]ISO[/TD]
[TD]Country[/TD]
[TD]Format[/TD]
[/TR]
[TR]
[TD]AU[/TD]
[TD]Australia[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]AT[/TD]
[TD]Austria[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]BE[/TD]
[TD]Belgium[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]BR[/TD]
[TD]Brazil[/TD]
[TD]99999[-999][/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]Canada[/TD]
[TD]A9A 9A9[/TD]
[/TR]
[TR]
[TD]DK[/TD]
[TD]Denmark[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]FI[/TD]
[TD]Finland[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]FR[/TD]
[TD]France[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]DE[/TD]
[TD]Germany[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]HU[/TD]
[TD]Hungary[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]IE[/TD]
[TD]Ireland[/TD]
[TD]A9A AAAA[/TD]
[/TR]
[TR]
[TD]IL[/TD]
[TD]Israel[/TD]
[TD]99999 99[/TD]
[/TR]
[TR]
[TD]IT[/TD]
[TD]Italy[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]JP[/TD]
[TD]Japan[/TD]
[TD]999-9999[/TD]
[/TR]
[TR]
[TD]LU[/TD]
[TD]Luxembourg[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]MY[/TD]
[TD]Malaysia[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]MX[/TD]
[TD]Mexico[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]NL[/TD]
[TD]Netherlands[/TD]
[TD]9999 AA[/TD]
[/TR]
[TR]
[TD]NZ[/TD]
[TD]New Zealand[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]Norway[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]PL[/TD]
[TD]Poland[/TD]
[TD]99-999[/TD]
[/TR]
[TR]
[TD]PT[/TD]
[TD]Portugal[/TD]
[TD]9999-999[/TD]
[/TR]
[TR]
[TD]RU[/TD]
[TD]Russia[/TD]
[TD]999999[/TD]
[/TR]
[TR]
[TD]SA[/TD]
[TD]Saudi Arabia[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]SG[/TD]
[TD]Singapore[/TD]
[TD]999999[/TD]
[/TR]
[TR]
[TD]KR[/TD]
[TD]South Korea[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]SE[/TD]
[TD]Sweden[/TD]
[TD]999 99[/TD]
[/TR]
[TR]
[TD]CH[/TD]
[TD]Switzerland[/TD]
[TD]9999[/TD]
[/TR]
[TR]
[TD]TR[/TD]
[TD]Turkey[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]UA[/TD]
[TD]Ukraine[/TD]
[TD]99999[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]United Kingdom[/TD]
[TD]AA9[9] 9AA[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]United States[/TD]
[TD]99999[-9999][/TD]
[/TR]
</tbody>[/TABLE]
A represents alphabet
9 represents number
[ ] represents optional
In Sheet2 I have the following input zip codes and the expected output:
[TABLE="width: 300"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Zip (Input)[/TD]
[TD]Zip (Output)[/TD]
[/TR]
[TR]
[TD]NL[/TD]
[TD]1613 LC[/TD]
[TD]1613LC[/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]J7J1C1[/TD]
[TD]J7J 1C1[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]CT179PA[/TD]
[TD]CT17 9PA[/TD]
[/TR]
[TR]
[TD]UK[/TD]
[TD]CM29BE[/TD]
[TD]CM2 9BE[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]74112[/TD]
[TD]74112[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]6354[/TD]
[TD]06354[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]207354607[/TD]
[TD]20735-4607[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]20735 4607[/TD]
[TD]20735-4607[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]20735-4607[/TD]
[TD]20735-4607[/TD]
[/TR]
</tbody>[/TABLE]
How do I convert the input string to a valid zip code based on the corresponding format?
Last edited: