$test = "a nor b neither"; say $test =~ /(.*?nor)/i && $1 !~ /neither/i ? 1 : 0;