I’ve used regular expression(regex) in javascript
as follows:
function chnColor(){
var str=document.getElementById("myelement").innerHTML;
str=str.replace(/(%)(.*)(%)/g,"<font color="red">$2</font>");
//Here $2 Means Anything in between % and % This is what you need to color
document.getElementById("myelement").innerHTML=str;
}
DEMO
Hope it helps! cheers :)!
solved How to color portion of text using css or jquery