in reply to Re: Regex negative word
in thread Regex negative word

That is not doing what you think. Consider:

use strict; use warnings; while (<DATA>) { print "matched $_" if /^[^cat)(?:]/; } __DATA__ cat dog dog cat aardvark ant catnip dogbone frog cat dog mouse dog cat cat dog elephant can of worms

Prints:

matched dog cat matched frog cat dog matched mouse dog cat

The following code excludes beginning cats and insists that dogs end:

use strict; use warnings; while (<DATA>) { print "matched $_" if /^(?!cat\b).*(?=\bdog$)/; } __DATA__ cat dog dog cat catnip dogbone aardvark ant frog cat dog can of worms

Prints:

matched frog cat dog

DWIM is Perl's answer to Gödel