Вариант для (){}[] 01function balance(a) {02 for (var d = /(\u005B|\u0028|\u007B)[^\u005B\u0028\u007B]*?$/,03 e = {04 "(": /\u0028[^\u007D\u005D]*?\u0029/,05 "[": /\u005B[^\u0029\u007D]*?\u005D/,06 "{": /\u007B[^\u0029\u005D]*?\u007D/07 }, b, c = !0; c;) b = a, a = a.replace(d, function (a, b) {08 return a.replace(e[b], "")09 }), b == a && (c = !1);10 return !/[\u005B\u005D\u0028\u0029\u007B\u007D]/.test(a)11};12 13 14alert(balance("{}({}123(45))")+"\n"+balance("{}{}1234][5")+"\n"+balance("<><(([]){}<[}}[[]]}}]>)>"))
01function balance(a) {02 for (var d = /(\u005B|\u0028|\u007B)[^\u005B\u0028\u007B]*?$/,03 e = {04 "(": /\u0028[^\u007D\u005D]*?\u0029/,05 "[": /\u005B[^\u0029\u007D]*?\u005D/,06 "{": /\u007B[^\u0029\u005D]*?\u007D/07 }, b, c = !0; c;) b = a, a = a.replace(d, function (a, b) {08 return a.replace(e[b], "")09 }), b == a && (c = !1);10 return !/[\u005B\u005D\u0028\u0029\u007B\u007D]/.test(a)11};12 13 14alert(balance("{}({}123(45))")+"\n"+balance("{}{}1234][5")+"\n"+balance("<><(([]){}<[}}[[]]}}]>)>"))