JSFiddle - React, Tailwind, and code Playground
HTML
<div id="msg">Hi, this is a Textnode _link_<br>
this is Textnode number 2
<br /><a href="http://abhi.cc">element node</a></div>
<br><br>
<br>
<br>
<br>
<b>This is how the output should be:</b><br>
-----------------------------------------------
<br>
Hi, this is a Textnode <a href="http://google.com">Google</a><br>
this is Textnode number 2
<br /><a href="http://abhi.cc">element node</a></div>
CSS
* { font:14px/22px Tahoma,Arial,Sans-serif }
JavaScript
$('#msg').contents().each(function() {
if(this.nodeType == 3) {
var u = this.nodeValue;
var reg = /_link_/g;
$(this).replaceWith(u.replace(reg,'<a href="http://google.com">Google</a>'));
}
});