If you want to understand what a specific regular expression is looking for there are lots of helpful online tools that will do this for you, my personal preference is http://regex101.com
The specific problem with your regular expression is that it assumes all postcodes are composed of one/two letters followed by one/two numbers and then a single number followed by two letters.
However this is not the case, as detailed in the wikipedia articles for UK Postcodes:
The 'outward' part identifies first the postcode area, using one or
two letters (for example L for Liverpool, RH Redhill and EH
Edinburgh). A postal area may cover a wide area, for example RH covers
north Sussex, which has little to do with Redhill historically apart
from the railway links, and Belfast (BT) covers the whole of Northern
Ireland. These letter(s) are followed by one or two digits (and
sometimes a final letter) to identify the appropriate postcode
district (for example W1A, RH1, RH10 or SE1P)
Where the 'outward' part means the first half of the post code.
Therefore in order to cover all valid UK post codes you need to add an optional letter component as already detailed in other answers you've received, reproducing @Martyn's suggestion for completeness of this answer:
/[A-Z]{1,2}[0-9]{1,2}[A-Z]?\s?[0-9][A-Z]{2}/i