Whole word regex matching and hyperlinking in Javascript
问题 I need a little help with Regular Expressions. I'm using Javascript and JQuery to hyperlink terms within an HTML document, to do this I'm using the following code. I'm doing this for a number of terms in a massive document. var searchterm = "Water"; jQuery('#content p').each(function() { var content = jQuery(this), txt = content.html(), found = content.find(searchterm).length, regex = new RegExp('(' + searchterm + ')(?![^(<a.*?>).]*?<\/a>)','gi'); if (found != -1) { //hyperlink the search