use strict; use warnings; my $orig_string = 'abababa'; my @tests = ( qr/(b)(?!.*b)$/ , qr/b(?!.*b)$/ , qr/b(?!.*b.*$)/ , qr/b(?=[^b]*$)/ ); foreach my $test_re ( @tests ) { my $scratch = $orig_string; print "$test_re\tdid", $scratch =~s/$test_re/x/ ? ' ' : "n't " , "match '$orig_string', yielding '$scratch'\n"; }