正则表达式中的字符后开始匹配

我想要的是

假设我有以下字符串:

"Abc def. 2. Ghi jkl. → 1. Mno 2. Pqrs 3. Tu 4 vx 5. yz..."

Now I want to write a regular expression in Python that matches and groups each list item after the character such that each group would contain the list item number and the content for that list item, like this:

('1', 'Mno')

('2', 'Pqrs')

('3', 'Tu 4 vx')

('5', 'yz..')

In other words, after I encounter I want to match patterns that look something like:

'([0-9]+)\.[" "]*(.*)'

I know that the obvious practical solution is to split the string and only search the section that comes after , but I'm more interested in a theoretical, maybe-not-so-practical solution using only regular expression, in order to get a better understanding of regular expressions.

我尝试过的

我试过这样使用后向:

'(?<=→)[" "]*([0-9]+)\.[" "]*(.*?)(?=[0-9]+\.|$)'

它找到了第一个匹配项,但是事情似乎变得更加复杂,因为它看起来好像我需要使用另一个后向匹配项来匹配所有非第一个匹配项。但是由于我不知道第一个列表项的长度,并且Python仅支持固定宽度的后向查找,因此我不确定如何继续。

评论