in reply to Finding words within a character set
Here is an algorithm - certainly not the best - that would work: If you could load your dictionary into memory:
Then it is a simple process of taking your input letters, say art and doing:my @words = <DICTIONARY>;
Beware of: upper/lower case in input and in the dictionary, the massive amount of memory the words array will consume...#! /usr/bin/perl -w use strict; my $input = 'art'; # Read words from a file instead. my @words = ('tar', 'rat', 'fake', 'at', 'unknown'); my $regex = qr{[$input]+}; my @matches = grep /^$regex$/, @words; print "$_\n" for @matches;
|
|---|