That's based on .NET regex syntax, but the terms in the expression are pretty universal.
I don't see the brace repeat structure {m,n} listed in the regex help. Does Directory Opus have a limited implementation of regular expressions and, if not, why does the above expression not work?
I'm not at all familiar with UK postcodes, so plese forgive me if I misunderstand that part of the problem.
Here in the US they are called zip codes and are 5 digit numbers followed by a - and a 4 digit number.
The 5 digit number is all that is needed, but knowing the 4 digit part can help speed delivery to inner city areas.
To start, I'll go directly to my first working answer to this problem.
Try
^[A-Z][A-Z]?[1-9][ ][0-9][A-Z][A-Z]?
It's flawed as all RegExp's are, but it is a start.
I'm still working on a reply to the remainder of your question.
I also know several other people who frequent this forum are quite good at the DOpus interpretation of RegExp's,
and my answer may soon fall.
I just wanted to be the first
The problem with regexps is there are so many "standards" to choose from. I think every program and language I use that supports regexps has a slightly different syntax or set of features that I have to remember. In TextPad you have to escape brackets etc. to make them work while in everything else you escape them to make them into normal characters... Sometimes I forget and spend ages wondering why stuff isn't working.
Regexps are limited anyway. I want to be able to parse text using function calls into a scripting language.
PS: Porc's regexp for UK postcosts looks good to me.