【发布时间】:2016-11-19 20:19:08
【问题描述】:
假设我们有文本,其中一些引号存储在表单中:
用户:报价
我们可以在一个文本中有多个引号。
Agatha Drake: She records her videos from the future? What is she, a
f**ing time lord? Is she Michael J. Fox?
Harvey Spencer: This is just like that one movie where that one guy
changed one tiny, little thing in his childhood to stop the girl of
his dreams from being a crackhead in the future!
如何从 python 中的文本中提取引号(她从...录制她的视频,这就像一部电影....)?
我试过了
re.findall('\S\:\s?(.*)', text)
但它没有做这项工作。
https://regex101.com/r/vH63Go/1
如何在 Python 中做到这一点?
【问题讨论】:
-
用户总是在行首吗?
(?m)^[^:\n]+:\s?((?:.+\n?)*)将是我的方法。 -
谢谢@Sebastian Proske。这就是我想要的
标签: python regex python-3.x extract