MassAutocomplete icon indicating copy to clipboard operation
MassAutocomplete copied to clipboard

Added changes to highlight function

Open ayotundeoludahunsi opened this issue 7 years ago • 0 comments

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>');
        };

ayotundeoludahunsi avatar Jun 29 '17 01:06 ayotundeoludahunsi