I'm having difficulty in understanding the output for the following use of replace in javascript for strings using regex. Please explain the value of 'temp' that will persist.
{
var temp='xxxx5678';
var format='x-$2';
temp= temp.replace(/(x*)([0-9]+)/, format);
console.log(temp);
}
Here is another sample test case.
{
var temp='12345678';
var format='x-$2';
temp= temp.replace(/(x*)([0-9]+)/, format);
console.log(temp);
}