Title kinda says it all. This is what I have right now:
const str = "(((111)00)(01)(02)))))";
const rgx = /\([^()]*\)/g;
str.match(rgx).forEach(function(m) {
document.body.insertAdjacentHTML('beforeend', m + '<br>');
});
Mine will get all nested parentheses if they are directly inside of the outer parentheses. However it will not work if I nest parentheses within another nested parentheses (Inception style).
Right now for the string "(((111)00)(01)(02))" it returns (111), (01), (02) in my example. I would like it to return (111), ((111)00), (01), (02).
Really my final goal is to check for balance and return true or false depending on the result.
Any help is appreciated. Thanks!