Javascript 将字符串中的连续数字转换为数组

Javascript 将字符串中的连续数字转换为数组,javascript,regex,Javascript,Regex,我有一个字符串,该字符串具有以下序列号: 1. this is some text 2. this is more text 3. this is even more text string.split(/(?=\d[.][ ])/g); 我想将其拆分为一个以数字开头的数组: ['1. this is some text', '2. this is more text', '3. this is even more text'] 我尝试了以下方法: 1. this is some text

我有一个字符串,该字符串具有以下序列号:

1. this is some text 2. this is more text 3. this is even more text
string.split(/(?=\d[.][ ])/g);
我想将其拆分为一个以数字开头的数组:

['1. this is some text', '2. this is more text', '3. this is even more text']
我尝试了以下方法:

1. this is some text 2. this is more text 3. this is even more text
string.split(/(?=\d[.][ ])/g);
当数字为1-9时,这种方法效果很好。然而,当数字>=10时,它就不能正常工作


关于如何让它工作,你有什么想法吗?

是的,这就是你需要改变的全部(试穿):

+
后面的
\d
告诉它匹配1个或多个


编辑:这个
\b
是一个单词边界,以确保你从开头就得到数字,而不是每个单独的数字。

这对我不起作用。9可以很好地工作,但它可以像这样拆分10:[…,'9.文本在这里,'1','0.十的文本在这里,'1','1.下一个十一的文本在这里']@Marc:很抱歉,但是我刚才添加的
\b
单词边界检查应该可以做到这一点。