We Recommend

Mastering Regular Expressions Mastering Regular Expressions
As this book shows, a command of regular expressions is an invaluable skill. Regular expressions allow you to code complex and subtle text processing that you never imagined could be automated. Regular expressions can save you time and aggravation. They can be used to craft elegant solutions to a wide range of problems. Once you've mastered regular expressions, they'll become an invaluable part of your toolkit. You will wonder how you ever got by without them.


Posted By

Scooter on 08/23/08


Tagged


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

DaveChild
dmitryfstyleca


Validate UK PostCode


Published in: Regular Expression 


URL: http://reusablecode.blogspot.com/2008/08/isvalidpostcode.html

Checks the validity of the format of a supplied UK postcode. Completely accurate validation is only possible by attempting to deliver mail to the address, and verifying with the recipient. Supports all six common postcode formats, Girobank, Father Christmas, British Forces Post Office, and overseas territories.

  1. ^([A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])\ [0-9][ABD-HJLNP-UW-Z]{2}|(GIR\ 0AA)|(SAN\ TA1)|(BFPO\ (C\/O\ )?[0-9]{1,4})|((ASCN|BBND|[BFS]IQQ|PCRN|STHL|TDCU|TKCA)\ 1ZZ))$

Report this snippet 

You need to login to post a comment.