Is there a way to pass a variable into a regex in jQuery/Javascript?
I wanna do something like:
var variable_regex = "bar";
var some_string = "foobar";
some_string.match(/variable_regex/);
In Ruby you would be able to do:
some_string.match(/#{variable_regex}/)
Found a useful post:
http://stackoverflow.com/questions/185510/how-can-i-concatenate-regex-literals-in-javascript