使用 PHP,我希望从包含编号列表的字符串中提取一个数组。
示例字符串:
The main points are: 1. This is point one. 2. This is point two. 3. This is point three.
将产生以下数组:
[0] => 1. This is point one.
[1] => 2. This is point two.
[2] => 3. This is point three.
字符串的格式可以变化 - 例如:
1. This is point one, 2. This is point two, 3. This is point three.
1) This is point one 2) This is point two 3) This is point three
1 This is point one. 2 This is point two. 3 This is point three.
我已经开始使用具有以下模式的preg_match_all :
!((\d+)(\s+)?(\.?)(\)?)(-?)(\s+?)(\w+))!
但我不确定如何匹配其余字符串/直到下一场比赛。
RegExr提供的示例