Coloring a text in a string using javascript



Hey guys ,

Actually I have a text field which is binded with a long text , need to color a specific character from the string. Got an idea of using replace function  replacing the text with a colored text using javascript , used the following script : (the rawValue contains text "this is only for testing")

var e = "BLAH";

this.font.fill.color.value = "0,56,101";

//e.value.font.fill.color = "0,56,101";

var str = this.rawValue;

str = str.replace(/ only /g, e);

this script works but it colors the entire string , the third line of script does not work(so commented it). Can we set color to the value of the variable e which I've defined above and pass that variable to replace function ???

Accepted Solutions (0)