JSFiddle - React, Tailwind, and code Playground
HTML
<body>
[~{ header }~]
<p>This is the home page</p>
[~{ footer }~]
</body>
JavaScript
function getMatches(string, regex) {
var matches = [];
var match;
while (match = regex.exec(string)) {
matches.push(match);
}
return matches;
}
var myString = $('body').html();
var myRegEx = /\[~\{ (\w+) \}~\]/g;
var matches = getMatches(myString, myRegEx);
console.log(matches[0]);