#!/usr/bin/perl use strict; my $string1 = "don"; # should both of these match? my $string2 = "donk"; # (you be the judge, and choose # your regex accordingly) my %regex = ( complem_char_class => qr/don[^t]/, zwid_neg_lookahead => qr/don(?!t)/, ); for my $regtyp ( sort keys %regex ) { print "\n"; for ( $string1, $string2 ) { my $result = ( /$regex{$regtyp}/ ) ? "succeeds" : "fails"; print "For $_ : match $result based on $regtyp\n"; } }