this I have written the perl script shown below. In this script postal
codes for Netherland, belgium, Italy, Ireland can be validated with
the use of regular expressions. Still I need to validate countries
like Greece, Norway, United Kingdom, Sweden, Finland, Schweiz,
Portugal, Austria, Luxembourg, France, Spain, Deutschland, Denmark. I
am not getting the regular expressions for these countries.
Can anyone help me out for these regular expressions??
Expand|Select|Wrap|Line Numbers
- $country = $ARGV[0];
- $zip = $ARGV[1];
- $countrycode = "";
- $invalid_zip = "";
- if($country =~ m/Netherland/)
- {
- $invalid_zip =1 unless ($zip =~ /[1-9][0-9]00 NL/);
- print "$country\t$zip\n;"
- }
- elsif($country =~ /Belgium/)
- {
- $invalid_zip =1 unless ($zip =~ /^([1-9]{1}[0-9]{3}$)/i);
- print "$country\t$zip\n;"
- }
- elsif($country =~ /Italy/)
- {
- $invalid_zip =1 unless ($zip =~ /^[0-9]{5}$/i);
- print "$country\t$zip\n;"
- }
- elsif($country =~ /Ireland/)
- {
- $invalid_zip =1 unless ($zip =~ /^\s*$|D\d+w?/i); ##Ireland does not have postal codes except for Dublin City
- print "$country\t$zip\n";
- }
- elsif($country =~ /Greece/)
- {
- $invalid_zip =1 unless ($zip =~ /^[1-8][0-9]{2}$|^[1-8][0-9]{2}[0-9]{2}$/i);
- print "$country\t$zip\n";
- }
- elsif($country =~ /Norway/)
- {
- $invalid_zip =1 unless ($zip =~ /^[0-9]{4}$/i);
- print "$country\t$zip\n";
- }
- if($invalid_zip)
- {
- print "Invalid Postal Code";
- }