我正在使用JavaScript解析一些文本。比方说,我有一些字符串:包含正则表达式匹配的拆分字符串
"hello wold <1> this is some random text <3> foo <12>"
我需要把下面的子字符串数组:每当我遇到<“数字”
myArray[0] = "hello world ";
myArray[1] = "<1>";
myArray[2] = " this is some random text ";
myArray[3] = "<3>";
myArray[4] = " foo ";
myArray[5] = "<12>";
注意,我劈裂字符串>序列
我试过用正则表达式分割字符串/<\d{1,3}>/
但是当我这样做的时候,我放弃了<“number”>序列。换句话说,我最终得到了“世界的和谐”,“这是一些随机文本”,“富”。请注意,我将字符串“< 1>”,“< 3>”和“< 12>”我想保留该字符串。我将如何解决这个问题?
可能重复[使用Javascript - string.split(正则表达式)保持分隔符](http://stackoverflow.com/questions/4204210/javascript-string-splitregex-keep-seperators) – outis 2012-02-19 19:34:48