I have textbox and user write a formula and I get the text from textbox to split the parentheses .By the way I'm not trying to calculate formula I try to just get strings .I'm trying to get strings from nested parentheses Here is my code:
var txt = "((a-b)/month)/(c+d)";
var reg = /^\((.+)\)$/;
var newTxt = txt.split('(');
for (var i = 1; i < newTxt.length; i++) {
var value = newTxt[i].split(')')[0];
if (value == "") {
value = txt.match(reg)[1];
}
console.log(value);
}
And my output is
(a-b)/month)/(c+d
a-b
c+d
But I'm trying to get string between parentheses like
(a-b)/month
a-b
c+d