How can I use a variable to remove all instances of a substring from a string?
(to remove, I\'m thinking the best way is to replace, with nothing, globally... right?)
You have to use the constructor rather than the literal syntax when passing variables. Stick with the literal syntax for literal strings to avoid confusing escape syntax.
var oldWordRegEx = new RegExp(oldWord,'g');
myString.replace(oldWordRegEx,"");