My String : "<p>Stacked"
I want to replace it to "<font color=' blue'><</font>p<font color='blue'>></font>Stacked
So I have used this : ⬇
var rox = /([<])([a-z1-9]+)([>])/;
function testInfo(phoneInput){
var startTag = "<font color='blue'>";
var endTag = "</font>";
var OK = phoneInput.value.replace(rox, function(x){
var lt = x.replace(/([<])/, startTag+'<'+endTag);
var gt = lt.replace(/([>])/ , startTag+'>'+endTag);
return gt;
});
It returns like this
<font color='blue'<font color='blue'>p<font color='blue'>></font>
It means when I am replacing the Stack
**<font color='blue'><</font>p<font color='blue'>></font>** But next time it is replacing the **">"** of the *font tag*. Lot *">"* of **p tag**.
Problem
How can I fix it? I am trying something to color/highlight code.