JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

JavaScript

var subject = "[test2][test]testing[/test][/test2]testinge2";
var myregexp = /\[([A-Z][A-Z0-9]+)[^\]]*\](.*?)\[(\/\1)\]/gi;
var match = subject.split(myregexp);
match = match.filter(Boolean);
var i = 0;
match = match.map(function tree(e) {
    e = e.split(myregexp).filter(Boolean);
    if (e.length > 1) e = e.map(tree);
    else e = e.toString();
    return e;
});
console.dir(match);
document.body.appendChild(document.createTextNode(match));v