I want to be able to concat two variables with a regular expression in the middle.
var t1 = "Test1"
var t2 = "Test2"
var re = new RegEx(t1 + "/.*/" + t2);
"Test1 this works Test2"
Try this (I use nodejs):
> var t1 = "Test1" > var t2 = "Test2" > var re = new RegExp(t1 + '.*' + t2); > re /Test1.*Test2/ > re.test("Test1 this works Test2") true
.*as stated in comments means any character repeated from 0 to ~
RegExpconstructor, but you can't have nested unprotected slashes delimiters