UK Postcode Regular Expression

Here is a UK postcode matching regular expression. I built it using a database of all the UK postcodes, so it does work for the strange ones. This regular expression will match the first part: ^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$