I’ll answer that in a second - I just thought of something. Regular Expressions use “escapes” all the time, and I’m concerned about what KM will do to some of them. For instance, if you have a backslash-n, will it become a newline instead? You’ll probably need to do some experimentation with this. Sounds like a PITA. Better you than me. 
Back to your question:
You’ll need to use code like this:
var s = "/te.t/i";
var regexp = eval("new RegExp(" + s + ")");
console.log("my Test".search(regexp));
The first line is just setting up the string, like you might get it from KM. In this case, it’s looking for “te” followed by any character followed by “t”, with the flag for ignore case. It was just the first thing that popped into my mind.
The second line is the thing that does all the work. It creates a new “RegExp” object (which is basically the same thing as if I had just hard-coded /te.t/i with no quotes).
I use an “eval” statement, which is a nasty little thing that converts the string into actual JavaScript, and runs it. The reason why “eval” is also known as “evil” is because it can execute literally any JavaScript code, and if you were to use it in a normal internet-facing web page, you’d be totally asking to get hacked. Fortunately, that’s not a problem here - If someone wants to hack this, they have access to the actual source code, so I think that’d be the better way to go - at least if I were the hacker. 
The last line just proves it works.
Of course, there are other ways to do this, but this is the simplest, my long-winded explanation notwithstanding. 