SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with UK Postal Code Regex

    HI

    Masters, here I m stuck with a problem.
    I have a website which calculates the distacne between 2 UK Locations based on Postal Code. Now, the matter is that Ireland and Scotland are both the parts of UK. Means UK = ENGLAND + IRELAND + SCOTLAND.

    I have a regex which is for England postal codes. I want the pattern to match scotland and ireland postcodes also. Please check the pattern below and let me know how can i do this ????

    /^[A-Za-z]{1,2}[0-9A-Za-z]{1,2}[ ]?[0-9]{0,1}[A-Za-z]{2}$/

    I read somewhere that the scheme of Post Code in Ireland wales scotland are all different.

    but i have to do this validation. Plz Help

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you'll find that Ireland (Eire) is not in the UK. Suggest you find an Irish forum and ask them how their postcodes are put together..
    isempty()

  3. #3
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Zeeshan,

    Have a look at PEARs Validate_UK, there is a postcode validation method in there.

    Cheers;
    Poncho
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  4. #4
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot. I hope there will be some one here from the UK and will add something....i m checking the pear thing at this moment. let me check then i will add here about that .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •