Seeking 7-letter words containing 2 Us
by danielbmartin from LinuxQuestions.org on (#5N3GH)
This topic is only a learning exercise.
Wanted: a list of English words which...
- are 7 letters long
- contain exactly 2 Us in any sequence
Examples: fulcrum and surplus are good
but cumulus and unusual are not.
My solution...
Code:WordList='/usr/share/dict/words'
sed -rn '/^.{7}$/p' $WordList \
|sed -rn '/u.*u/p' \
|sed -r '/u.*u.*u/d'This works but it seems clumsy.
Brainteaser: is there an elegant RegEx which could do this with only one sed?
Daniel B. Martin
.
Wanted: a list of English words which...
- are 7 letters long
- contain exactly 2 Us in any sequence
Examples: fulcrum and surplus are good
but cumulus and unusual are not.
My solution...
Code:WordList='/usr/share/dict/words'
sed -rn '/^.{7}$/p' $WordList \
|sed -rn '/u.*u/p' \
|sed -r '/u.*u.*u/d'This works but it seems clumsy.
Brainteaser: is there an elegant RegEx which could do this with only one sed?
Daniel B. Martin
.