Skip to content

Added changes to highlight function #73

@ayotundeoludahunsi

Description

@ayotundeoludahunsi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions