【发布时间】:2019-12-08 16:49:51
【问题描述】:
我想在一个字符串中搜索 3 个单词并将它们放在一个列表中 类似:
sentence = "Tom once got a bike which he had left outside in the rain so it got rusty"
pattern = ['had', 'which', 'got' ]
答案应该是这样的:
['got', 'which','had','got']
我还没有找到以这种方式使用re.finditer 的方法。遗憾的是我需要使用finditer
而不是findall
【问题讨论】:
-
那你为什么要标记 findall?
-
你试过什么?你能展示一下你的尝试吗?
标签: python regex python-3.x findall