Skip to content

Instantly share code, notes, and snippets.

@jmshoffs0812
Created August 19, 2011 02:18
Show Gist options
  • Save jmshoffs0812/1155875 to your computer and use it in GitHub Desktop.
Save jmshoffs0812/1155875 to your computer and use it in GitHub Desktop.
Find all words in a given list with three consecutive pairs of letters
// Derped original regex: /(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz){3}/
// New regex provided by @ryan_richt
var fs = require('fs'),
lazy = require('lazy'), // https://github.com/pkrumins/node-lazy
re = new RegExp(/(([a-z])\2){3}/),
word;
new lazy(fs.createReadStream(process.argv[2] || '/usr/share/dict/words'))
.lines
.forEach(function (line) {
word = line.toString('ascii').toLowerCase();
if (re.test(word)) console.log(word);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment