I have a challenging mission in JS string manipulation: There is a HTML string in which I need to replace a word at a specific word index. The word index is the number of the word when ignoring the HTML tags.
For example, here is the HTML string:
<span style="font-family:Times New Roman;">At times like this I don't know what to
do. Other times I have no problem.</span>
The task is to replace word number 2 in the html (which is the word times) with the text: <span style="color:red;">times</span>
So the final HTML string should be:
<span style="font-family:Times New Roman;">At <span style="color:red;">times</span>
like this I don't know what to do. Other times I have no problem.</span>
Any ideas for this challenge?