I have been trying to do a simple replace using regex as see below. I was following this and this. But for some reason the code below just does not work. I honestly can't see what I did wrong.
var equ = "77^7x";
var base = "77";
var exp = "7x";
var output = equ;
var replace = base + "^" + exp;
var regex = new RegExp(replace, "gi");
var newOutput = output.replace(regex, "Math.pow(" + base + "," + exp + ")");
console.log(newOutput);
The output is not Math.pow(77^7x) as expected
I am using the python regex library