How do I negate a ZSH regular expression test?

Solution 1:

A negation of the entire test would be the easiest. Mostly because it's easy to remember and doesn't depend on any specific condition syntax:

if ! [[ $host =~ '^myhost[0-9]+$' ]]
then
    # Do stuff
    # ...
fi