var params = ['tom' , 'harry'];
var string = 'hello $1 and $2 how aa are you $1 and $2';
What i tried
var params = ['tom' , 'harry'];
var string = 'hello $1 ,$2 how aa are you $1 , $2';
var temp;
for(var i = 0; i<params.length ; i++)
{
temp = string.replace(/[$1]+/g,params[i]);
}
Firefox console wrong output : "hello harry ,harry2 how aa are you harry , harry2"
Final Output : hello tom and harry how are you tom and harry