如何将"somestring\correct{s}\wrong{g}somestring\correct{w}somestring"
等JavaScript字符串拆分为["somestring", "\correct{s}", "\wrong{g}", "somestring", "\correct{w}", "somestring"]
答案 0 :(得分:0)
尝试.match
:
var arr = str.match(/\\?[a-z]+(?:\{[a-z]\})?/g)
应该工作!