JSFiddle - React, Tailwind, and code Playground

JavaScript

var string="(this is fine and does not need attention) This is also [fine] This is bad( and needs to be edited This [is (also) bad as is this} bad", oldstring;

// First remove non-brackets:
string=string.replace(/[^{}[\]()]/g,"");

// Then remove bracket pairs recursively
while (string!==oldstring) {
  oldstring=string;
  string=string.replace(/({}|\[\]|\(\))/g,"");
}

document.write(string);