I want a regex to match all outermost pair of bracket into array with their contents in them even if their content could be nested. This was my code
this gives expected output
console.log("52*((6*8)-4+3^(7+5))".match(/ *(\([^]*\)) */g)) /* => [ '((6*8)-4+3^(7+5))' ] correct*/
But
this doesn't give expected output
console.log("52*(6*8)-4+3^(7+5)".match(/ *(\([^]*\)) */g)) /* => [ '(6*8)-4+3^(7+5)' ] incorrect expected [ '(6*8)', '(7+5)' ]*/
please if anyone understand this problem help me