I know that it is easy to match anything except a given character using a regular expression.
$text = \"ab ac ad\"; $text =~ s/[^c]*//g; # Match anything, except
You can easily modify this regex for your purpose.
use Test::More 0.88; #Match any whole text that does not contain a string my $re=qr/^(?:(?!ac).)*$/; my $str='ab ac ad'; ok(!$str=~$re); $str='ab af ad'; ok($str=~$re); done_testing();