JS Regex
Because regex is awesome, I decided to write a little note about it. I don’t use a lot of regex in my JavaScript. (To be sure, I don’t use a lot of regex, in general – regex is a bit of a pain in the ass.)
But if I want to create dynamic regex using JS, I can use the RegExp constructor like so:
var str = "Your mom";
var reg_ex = new RegExp('^start then ' + str + ' then finish$', 'g');
which gives us:
/^start then Your mom then finish$/g
Neato.