JSFiddle - React, Tailwind, and code Playground

JavaScript

alert(wikifyText("[[", "]]", "There are cars, be careful, carefully, and with great care!! Blue Öyster Cult.", ["text", "hoogahjush", "wikify", "car", "careful", "carefully", "great care", "great", "there", "öyster"]));

function wikifyText (startString, endString, text, list) {
    list = list.map( function (str) {
        var first = str.charAt(0);
        str = first.toUpperCase() + first.toLowerCase() + str.substr(1);
        str = str.replace( /(\W)/ig, '\\$1' );
        return str.replace( /^(\\?.\\?.)/, '[$1]' );
    });
    list.sort();
    list.reverse();
    var re = new RegExp( '(^|\\W)(' + list.join('|') + ')(?=(e?s)?\\W)', 'g' );
    return text.replace( re, '$1' + startString + '$2' + endString );
}