Throw an error if unable to find a not matching string

Throw an error if unable to find a not matching string for the
regular expression of some variable.