Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 匹配直到空格数字组合_Php_Regex_Regex Greedy - Fatal编程技术网

Php 匹配直到空格数字组合

Php 匹配直到空格数字组合,php,regex,regex-greedy,Php,Regex,Regex Greedy,我的目标是从任何空格+数字++空格(包括)匹配到下一个空格(不包括)。例如: 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

我的目标是从任何空格+数字++空格(包括)匹配到下一个空格(不包括)。例如:

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
提供的答案是可以的

(?:(?!\s\d+\)).)+
但是如果我在模式中嵌入了类似的模式,如何避免呢?

更新 唯一的比较或条件是主枚举将增加,而不是减少:1)2)3)4)5)依此类推。
但是,嵌入的枚举总是从1)再次开始,因此基本上,如果嵌入的枚举小于或等于主枚举,则我们将跳过它。

试试这个:

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

请参见演示:

为什么要在每行末尾包含
[^,因为有时我会在每行末尾添加