MassAutocomplete
MassAutocomplete copied to clipboard
Added changes to highlight function
function highlight(str, term) { --------------------------------- ADDED CHANGES ---------------------------------------------------------- term = term.replace(/^\s+|\s+$/g, '') //replace trailing spaces term = term.replace(/\s\s+/g, '|') //replace all spaces, tabs, newlines by | => regex OR, //instead of using "term" as a single word
var highlight_regex = new RegExp('(' + term + ')', 'gi');
return str.replace(highlight_regex,
'<span class="highlight">$1</span>');
};