if ($string =~ /\A(?:(?!regex).)*\z/s) { # doesn't contain regex anywhere }