How do I replace "$id" with a value? I need to replace the regular expression in the sql string with a value. I'm trying to use RegExp.
const src = "SELECT * FROM users WHERE id=$id";
const myFind = "$id";
// $id is the property of the object. example { $id: 123,}
const find = new RegExp(myFind, 'g');
const repl = 123;
const _completeSQL = src.replace( find, repl);
console.log(`_completeSQL ${_completeSQL}`);
My attempt fails because $ is a regular expression.