JSFiddle - React, Tailwind, and code Playground

by naryad

JavaScript

//recursively removes all the text between square brackets
var str = "abc[1[2[]3]4]def";
while (str != (str = str.replace(/\[[^\[\]]*\]/g, "")));
document.write(str);