Question:
I have this expression:Answer:
You’d need recursion, but JavaScript’s regular expressions don’t have support for recursion. So create a simple parser that breaks down the string into words, and then keeps track of the depth of nesting parentheses. Collect the words, and each time that depth is 0, output (and clear) that collection:If you have better answer, please add a comment about this, thank you!