I want to convert <font>
element to <span>
element like this using regex:
Input:
[some strings...]<span [something]></span><font ...>[sometext]</font>[some strings...]
Output:
[some strings...]<span [something]>[sometext]</span>[some strings...]
Note: The input/output is a string.
In shortly, I want to remove the <font>
element and move the contents of that into <span>
element keeping the attributes of the <span>
element.
I've tried this:
const rx = /<span(.*?)><\/span>([^<\\s]+?|\\s*)<font(?:\\s+[^>]*)?>(.*?)<\/font>/gi;
inputStr.replace(rx, function(match, p1, p2, p3) { return `${p2}<span${p1}>${p3}</span>`; });
However it doesn't work.
Can anyone help me?