I am looking at http://www.w3schools.com/jsref/jsref_replace.asp and the specific example at: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_replace3
var str="Mr Blue has a blue house and a blue car";
var n=str.replace(/blue/gi, "red");
And the result of N would be:
Mr red has a red house and a red car
I want the result to be:
Mr Red has a red house and a red car
With the first-replaced occurance to be capitalized like the original text to be replaced.
Is there a way to do this?