I am trying to create something similar to this:
var regexp_loc = /e/i;
except I want the regexp to be dependent on a string, so I tried to
You need to convert RegExp, you actually can create a simple function to do it for you:
function toReg(str) { if(!str || typeof str !== "string") { return; } return new RegExp(str, "i"); }
and call it like:
toReg("something")