I've already answered once, making the point that it's not possible to come up with a 100% correct England-only regex (since the postcode areas don't lie along political boundaries).
However I've dug a bit deeper into this, and ... well it is possible, but it's a lot of work.
To verify an England-only postcode, you need to exclude the non-English postcodes. The easy ones are:
- BT (Northern Ireland)
- IM (Isle of Man)
- JE (Jersey)
- GG (Guernsey)
- BF (British Forces)
- BX (non-geographic UK postcodes)
- GIR (Girobank, which is also non-geographic)
(I'm not going to mention UK-style postcodes for territories outside the UK, like St Helena, Gibraltar etc. Technically speaking, the Isle of Man and Channel Islands aren't part of the UK either, but they're much nearer by, and more closely tied into the Royal Mail system in the UK.)
The purely Scottish postcode areas are (as you mentioned):
ZE,KW,IV,HS,PH,AB,DD,PA,FK,G,KY,KA,EH,ML
DG and TD are nominally Scottish, and are for the most part in Scotland. However some areas extend over the Scotland-England border as follows:
- DG16 - a tiny bit in England
- TD9 - a tiny bit in England
- TD12 - half in England
- TD15 - mostly in England
The breakdown is as follows:
DG16 is in Scotland except for the following English postcodes:
TD9 is in Scotland except for TD9 0T[JPRSTUW]
TD12 has only one sector (TD12 4), which is spread roughly half and half across England and Scotland:
- TD12 4[ABDEHJLN] are in Scotland
- TD12 4[QRSTUWX] are in England
TD15 is the most complicated. There are 3 sectors, of which TD15 2 and TD15 9 are entirely in England.
TD15 1 is split across England and Scotland.
Postcodes beginning as follows are in Scotland:
... except for these English postcodes:
All other postcodes in TD15 1 are in England, except for those beginning as follows:
- TD15 1B
- TD15 1S (i.e. TD15 1S[ABEJLNPWXY])
- TD15 1U (i.e. TD15 1U[BDENPQRTUXY])
... which are all in England, with the exception of the following postcodes which are in Scotland:
- TD15 1BT
- TD15 1S[UZ]
- TD15 1U[FGHJLSZ]
The English postcode areas CA and NE lie on the other side of the England-Scotland border, however they never extend into Scotland.
In fact, the last two letters of a UK postcode is based on how the postman actually delivers post (as far as I'm aware), so it's not given for granted that it will fall inside a political boundary. Thus if there's a group of houses which straddle the border, then it's possible that the entire postcode (i.e. at the most fine-grained level) does not lie entirely within either England or Scotland. E.g. TD9 0TJ and TD15 1UZ are very close to the border, and I don't really know for sure if they're entirely on one side or not.
The England-Wales border is also complicated, however I'll leave this as an exercise for the reader.