my $string = 'bet'; use re qw(debug); my $rx1 = qr/b(?:a|e)t/; $string =~ /$rx1/; my $rx2 = qr/b[ae]t/; $string =~ /$rx2/;