function splitTag(str) { const tokens = []; for (let i = 0; i < str.length; i++) { if (str[i] === "<") { let tag = ""; while (str[i] !== ">") { tag += str[i]; i++; } tag += str[i]; tokens.push(tag); } else { tokens.push(str[i]); } } return tokens; } const test = "你啊后啊撒发我发<blod>你好啊啊啊啊</blod>"; console.log(splitTag(test));
Standard input is empty