Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: regex for word puzzle

by Anonymous Monk
on May 17, 2011 at 02:46 UTC ( #905194=note: print w/replies, xml ) Need Help??


in reply to Re: regex for word puzzle
in thread regex for word puzzle

Assume your rack is rtesamcna. Assume also you have the list of valid words in TWL.txt. The following grep command will show you words formed using only letters in your rack, but it will use any number of the letters:

grep -i '^[rtesamcna]*$' TWL.txt

Not quite what you want. You don't want words with more than 1 R, or more than 2 A's. So we filter it out:

grep -i '^[rtesamcna]*$' TWL.txt | grep -iEv 'r.*r|t.*t|e.*e|s.*s|a.*a.*a|m.*m|c.*c|n.*n'

And finally, to show anything with at least 9 letters:

grep -i '^[rtesamcna]*$' TWL.txt | grep -iEv 'r.*r|t.*t|e.*e|s.*s|a.*a.*a|m.*m|c.*c|n.*n' | grep ...... +...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://905194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2018-10-16 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (89 votes). Check out past polls.

    Notices?