in reply to Regex (lookahead) Confusion
sub no_dups { my $in = join( '', sort split '', shift ); ( my $out = $in ) =~ y/smtwhfa/smtwhfa/s; $out =~ y/smtwhfa//cd; print "no dupes $in\n" if length $in == length $out; } no_dups( 'afhwtms' ); no_dups( 'smtthfa' ); no_dups( 'smatwhfa' ); no_dups( 'afhwtmsz' );
Update: Ooop, didn't consider characters not in the allowed alphabet. Added second y/// to correct.
|
|---|