Regex to find a match word/phrase in returned data?
Okay, so this is my code thus far.
function(data) {
var output = '<div class="gs-title">';
$.each(data.data, function(i, article) {
});
output += '</div>';
$("##resultarea").replaceWith(output);
});
When the data is returned from the request, I want to highlight the search word that's found in the paragraph by putting it in a separate class. I found this regex:
pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
However, when I test this
http://www.regexpal.com/ site, it does not work. I want to be able to highlight the word anywhere it appears/found on the paragraph/summary texts.