A UK postcode is not a regional number, it is close to a delivery instruction. The Office for National Statistics describes it as an outward code of two to four characters and an inward code of exactly three — a digit followed by two letters — where the outward part identifies the postcode area and district and the inward part narrows to a sector and then to a specific run of properties. A postcode is only one part of the address block; use the street, post town and full postcode when constructing a postal label.
That precision shapes the block. The postcode goes on its own line at the bottom, in capitals, and the post town sits on the line above it, also conventionally in capitals — the post town is a sorting destination rather than the town the resident would name, so it does not always match the local place name. House number comes before the street name, unlike Germany.
For validation the trap is the format itself. The outward code varies in length between two and four characters, so a fixed-width rule fails; the space is conventional rather than mandatory; and there are real formats that a naive regex rejects, including single-letter areas and the postcodes with an inward code that looks like an outward one. Treat it as a lookup against a postcode file, and as a variable-length uppercase string everywhere else.
This generator emits the geographic half of the code and generates the rest. Every UK address here is pinned to one of 15 real cities and carries a real outward code for it — NG1 for Nottingham, RG1 for Reading — with the sector and unit characters invented. The complete code and street combination is not checked against a delivery-point file. An invented inward code may be unassigned or coincide with a real one; the outward code alone does not validate the full address.