JSFiddle - React, Tailwind, and code Playground

HTML

<p>This is some hello copy. In this copy hello is the word</p>
<p>This is some copy. In this copy the word <a href="">blah blah hello blah</a></p>

JavaScript

var searchTerm = "hello";

$('p:contains("' + searchTerm + '")').each(function(){
    var searchString = $(this).html();
    var searchIndex = searchString.indexOf(searchTerm);
    var startString = searchString.substr(0 , searchIndex);
    var endString = searchString.substr(searchIndex + searchTerm.length);
    if(endString.match(/<\/a>/g)) return;
    $(this).html(startString + "<a href=''>" + searchTerm + "</a>" + endString);
});