var func = function (s) { var strs = []; var index = []; return strs[0]; } console.log(func("abc3[aa2[b]]2[c]ttt"))