JSFiddle - React, Tailwind, and code Playground
HTML
<p>This is a word hello, yes hello</p>
<p>This is a <a href="orig">word hello</a></p>
JavaScript
$(document).ready(function() {
var needle = 'hello';
$('p').each(function() {
var me = $(this),
txt = me.html(),
found = me.find(needle).length;
if (found != -1) {
txt = txt.replace(/(hello)(?!.*?<\/a>)/gi, '<a href="">$1</a>');
me.html(txt);
}
});
});