Skip to content

Instantly share code, notes, and snippets.

@amix
Created December 20, 2013 22:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amix/8063003 to your computer and use it in GitHub Desktop.
Save amix/8063003 to your computer and use it in GitHub Desktop.
// JavaScript that solves http://regex.alf.nu/
// Run in Chrome or Firefox console
// Enjoy ;-)
// Some people, when confronted with a problem, think
// “I know, I'll use regular expressions.”
// Now they have two problems.
for(var lvl in levels) {
var fn = function(lvl) {
jump(lvl);
var bad = levels[lvl].bad;
var bad_w = [];
for(var i in bad) {
bad_w.push('^' + bad[i].replace(/\*/g, '\\*') + '$');
}
var reg_exp = "^((?!"+ bad_w.join('|') +").)*$";
document.getElementById("regex").value = reg_exp;
retest();
save();
}
setTimeout(fn.bind(window, lvl), lvl*1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment