This is a really good effort, but it fails if characters not matching the given character set are included in the string.
Unfortunately, I don't have a solution, either because in my mind, there would have to be a lookbehind on a string of variable length, which (of course) will not work.
#!/usr/bin/perl
use strict;
use warnings;
while(<DATA>) {
chomp;
if (! /([smtwhfa])(?=.*?\1)/) {
print "$_ : OK\n";
}
else {
print "$_ : Not OK\n";
}
}
__DATA__
swma
smqa
smsa
fhtm
ttma
t2ms
__END__
swma : OK
smqa : OK
smsa : Not OK
fhtm : OK
ttma : Not OK
t2ms : OK