use strict; use warnings; my $str = q{abcdceefghfty}; for my $ch (q{a} .. q{z}) { my $matchTxt = q {\A} . qq{[^$ch]*($ch)} . q {(?!.*\1)}; my $rxUniq = qr{$matchTxt}; print qq{"$ch" unique in "$str"\n} if $str =~ $rxUniq; }