Python - 提取子字符串列表

Siv*_*lam 0 python regex

如何根据python中的某些模式提取子字符串列表?

例如,

str = 'this {{is}} a sample {{text}}'.
Run Code Online (Sandbox Code Playgroud)

预期结果:包含'is'和'text'的python列表

And*_*ark 14

>>> import re
>>> re.findall("{{(.*?)}}", "this {{is}} a sample {{text}}")
['is', 'text']
Run Code Online (Sandbox Code Playgroud)