'Better way to replace dot(.) with comma(,) only in specific part of the string

var a = '<span class="test">33.3;34.55</span><img src="../../../test.gif" onclick=testThis(''open'')><span class="test">33.3;34.55</span><img src="../../../test.gif" onclick=testThis(''open'')>0.22';

Here, I need to replace dots in all parts of the string except in src and onclick. I have used two for loops to replace these tags and data with a placeholder. And replaced all dot with comma.

'<span class="test">33,3;34,55</span><img src=src_ph onclick=onclick_ph><span class="test">33,3;34,55</span><img src=src_ph onclick=onclick_ph>0,22';

But now I need those tags and data again. For this I have to make use of forloop again. Is there better solution? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source