We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

zingo on 07/01/08


Tagged

regex cli perl statistic


Versions (?)


Words with many doubled letters


Published in: Bash 


URL: http://www.leancrew.com/all-this/2008/07/words-with-many-doubled-letters/

  1. # words with three consecutive doubled letters
  2. perl -ne 'print if /(.)\1(.)\2(.)\3/' /usr/share/dict/words
  3.  
  4. # words with three doubled letters, regardless of whether they’re consecutive.
  5. perl -ne 'print if /(.)\1.(.)\2.(.)\3/' /usr/share/dict/words
  6.  
  7. # words with four doubled letters
  8. perl -ne 'print if /(.)\1.*(.)\2.*(.)\3.*(.)\4/' /usr/share/dict/words

Report this snippet 

You need to login to post a comment.