Validating date in c
There is a brief description about the data and the attached xml schema provides a regular expression.
It may not be exactly what you want but would be a good starting point.
You can check that a postcode is in the correct format using a regular expression; not that it actually exists.
After playing with it a bit (in python), I factored it out to a slightly more compact but equivalent regex which also allows for an optional space: ([a-z A-Z](? Any discrepancies beyond that and the Royal Mail themselves don't even mention them in their literature (see start reading from page 17)!
Note: In the Royal Mail's own literature (link above) there is a slight ambiguity surrounding the 3rd and 4th positions and the exceptions in place if these characters are letters.
Postcodes are arbitrarily complex and constantly changing.
For instance, the outcode does not, and may never, have every number between 1 and 99, for every postcode area.