【发布时间】:2019-11-19 12:57:27
【问题描述】:
我知道如何在两个标记之间捕获子字符串的单个实例:
Python 3 How to get string between two points using regex?
我用这个字符串测试了这个方法:
text = 'blah.blah${capture1}.${capture2}'
我想获取这些标记“${”和“}”之间的所有子字符串,但它只获取第一个。
>>> text = 'blah.blah${capture1}.${capture2}'
>>> found = re.search('\$\{(.+?)\}', text)
>>> found.groups()
('capture1',)
>>> len(found.groups())
1
>>>
我如何获得所有这些?
【问题讨论】: