Regex to match all outermost pair of bracket into array

Multi tool use
Regex to match all outermost pair of bracket into array
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
/((.*)/)g
Apart from abusing regex features that elevate it above regular expressions, parsing nested brackets of unknown depth is impossible.
– ASDFGerte
Jul 1 at 12:49
@Alex I just tried it and it still show same thing as above
– Young Chiagoziem Nwadike
Jul 1 at 12:50
Possible duplicate of Regular Expression to match outer brackets
– ASDFGerte
Jul 1 at 12:51
Note: Parsing mathematical expressions is often done by evaluating the innermost brackets one after another, which is possible, because you don't have to care about potentially nested brackets. Using something else than regex to parse it the way you want to is an option aswell, of course.
– ASDFGerte
Jul 1 at 13:00
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
/((.*)/)g
try that.– Alex
Jul 1 at 12:42