Python正则表达式匹配一段英文中包含关键字的句子

Python正则表达式匹配一段英文中包含关键字的句子

1.问题/需求

在含有多行文字的英文段落或一篇英文中查找匹配含有关键字的句子。

例如在以下字符串:

text = """Today I registered my personal blog in the cnblogs and wrote my first essay. 
The main problem of this essay is to use python regular expression matching to filter out 
sentences containing keywords in the paper. To solve this problem, I made many attempts 
and finally found a regular expression matching method that could meet the requirements 
through testing. So I"ve documented the problem and the solution in this blog post and 
shared it for reference to others who are having the same problem. At the same time, 
this text is also used to test the feasibility of this matching approach. Some additional 
related thoughts and ideas will be added to this blog later."""
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » Python正则表达式匹配一段英文中包含关键字的句子