JSFiddle - React, Tailwind, and code Playground
HTML
<div id="myelement">
Hi how do I color %this%?
</div>
JavaScript
function chnColor(){
str=document.getElementById("myelement").innerHTML;
str=str.replace(/(%)(.*)(%)/g,"<font color='red'>$2</font>");
document.getElementById("myelement").innerHTML=str;
}
chnColor();