JSFiddle - React, Tailwind, and code Playground

JavaScript

var s = "TEST TEST TEST TEST",
    re = /\b(TEST)\b/g,
    match;
while (match = re.exec(s)) {
    document.write('<p>Matched from index ' + match.index + ' to index ' + re.lastIndex);
}