JSFiddle - React, Tailwind, and code Playground

JavaScript

var message = "TEST";
var regExp = /(^|\s)(TEST)(\s|$)/;

["TEST", " TEST", "TEST ", " TEST ", "toto TEST tata"].forEach(function (s) {
    if (!regExp.test(s)) {
        document.write("<p>Match failed " + s);
        return;
    }
    document.write("<p>Matched: " + regExp.exec(s));
});
["totoTEST tata"].forEach(function (s) {
    if (regExp.test(s)) {
        document.write("<p>Failed failing " + s);
        return;
    }
    document.write("<p>Correcty failed: " + s);
});