I want to replace every word starting with %
with the same word without the %
and changing its color to green.
However, all I can do is remove the %
without changing colors.
Is there something I am missing here?
var text = "Lite %match Color"
text = text.replace(/%(.*?)/g, "<span style='color: green'>$1</span>")
document.getElementById("output").innerHTML = text
<label id="output"></label>