There is one capability explicitly documented in gettytab(5) as stupid: he. And it is indeed. It was meant to facilitate system's hostname modification, but is hardly usable in practice because it allows very limited editing (e.g., it depends on particular hostname, that is, non-generic).
Using regex(3) instead gives more freedom, does not complicate the code very much, and makes a lot more sense, in turn making he less stupid and actually useful. To keep implementation simple, currently there is no explicit substitution involved (regex(3) API does not provide this functionality).
Proposal is to treat he as POSIX "extended" regular expression, which is matched against the hostname. If there are no parenthesized subexpressions in the pattern, entire matched string is used as final hostname. Otherwise, all matched subexpressions are concatenated together use the first matched subexpression. If pattern does not match, original hostname is not modified.
This allows, as an example, to mimic login prompt which is often seem under GNU/Linux, where short hostname (nodename) precedes actual login: text:
default:\
:he=[\^.]+:\
:cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%t)\r\n\r\n%h :sp#1200:\
:if=/etc/issue:
Or, to conceal nodename and display only the domain part:
default:\
:he=[\^.]*(\\..*):\
:cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (<hidden>%h %t)\r\n\r\n:sp#1200:\
:if=/etc/issue:
As for backwards compatibility (@ and # characters-based editing), I did not include it because, well, it is indeed utterly stupid and the change would not affect normal system behavior anyway. Full-featured s/pattern/replacement/ abstinence is more tough; it would be nice to have, but that comes with cost of parsing substitution string (see regsub() function in sed(1) code for example). Since getty(8)'s output is generally only seen by administrators nowadays, I was keen on keeping it simple.
Opinions?