JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = "some text [[ test 1 [[ test 2 \r\n\n]] ]] other \ntext";

str = str.replace(/\[[\s\S]*\]/gm, "");

alert(str);