匹配到 space 个数字组合

match until space digit combination

我的目标是从任何 space+digit+)+space 匹配到下一个排除。例如:

1) this is an example 2) yet another example 1) with embedded pattern 2) another embedded pattern 3) still another 4) final

结果:

1) this is an example 
2) yet another example 1) with embedded pattern 2) another embedded pattern 
3) still another 
4) final

Wiktor回答的还行,

(?:(?!\s\d+\)).)+

但是如果我在图案中嵌入了相似的图案怎么办,如何避免这种情况?

更新

唯一的比较或条件是主要枚举会增加,永远不会减少:1) 2) 3) 4) 5) 等等。
但是,嵌入的枚举总是从 1 开始) 同样,所以基本上如果嵌入的小于或等于主要的,那么我们就跳过它。

试试这个:

(\d+\) [A-Za-z+ ]+)

查看演示:https://regex101.com/r/T8nadr/1