in reply to regex for word puzzle
This is anagramming, and the nicest solution is well-known here. Split your string into characters, sort them, and rejoin them. Compare against a hash with keys made the same way from your dictionary or wordlist.
my %dict = do { open my $fh, '<', '/usr/dict/words' or die $!; map {chomp; join( '', sort split //, lc $_), $_} <$fh>; }; my $canon = join '', sort split //, lc 'RTESAMCNA'; print $dict{$canon} if exists $dict{$canon};
No regex or combinatorial excess needed.
After Compline,
Zaxo
|
|---|