Matches all standard UK postcodes whether partial (outward) or full (outward and inward), spaces optional. To enforce spaces remove the ? after (?:\s). There are a few letters not currently in use, this test does not seek to exclude them.
The only known postcode this will not validate for is GIR 0AA the special sort code created for Girobank.