JSFiddle - React, Tailwind, and code Playground

HTML

<p>This is a <a href="orig">linked hello</a>, a plain hello, another plain hello</p>
<p>This is a plain hello followed by a <a href="orig">linked 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.*?>).]*?<\/a>)/gi, '<a href="">$1</a>');
            me.html(txt);
        }
    });
});