【发布时间】:2013-04-08 14:37:31
【问题描述】:
我正在尝试从文本中提取包含指定单词的所有句子。
txt="I like to eat apple. Me too. Let's go buy some apples."
txt = "." + txt
re.findall(r"\."+".+"+"apple"+".+"+"\.", txt)
但它正在返回我:
[".I like to eat apple. Me too. Let's go buy some apples."]
而不是:
[".I like to eat apple., "Let's go buy some apples."]
有什么帮助吗?
【问题讨论】:
标签: python regex text-segmentation