i want to replace specific amount of white-spaces from a String at the beginning and i can use
replace(/^\s{2}/g,"");
and it works .but 2 should be changed according to a value of a variable .so i need to construct a new RegExp()
so i used
var lead=2;
var regex = new RegExp("\^\\s{" + lead + "}//g");
alert("regex "+regex);
real output
/^\s{2}\/\/g/
expected output
/^\s{2}/g
could you help me to fix this problem.tnx