my $str = "..."; if ($str =~ /^(?:(?!odd).)*weird/s) { # we found "weird" without looking at odd }