Created
August 19, 2011 02:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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