Skip to content

Instantly share code, notes, and snippets.

@amix
Created Dec 20, 2013
Embed
What would you like to do?
// 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