正则表达式提取具有匹配单词的整个句子

编程入门 行业动态 更新时间:2024-10-11 19:22:59
本文介绍了正则表达式提取具有匹配单词的整个句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在整个文本中提取带有flung"一词的句子.

I would like to extract sentences with the word "flung" in the whole text.

例如,在下面的文本中,我想提取句子就好像一只手抓住了它们的中心并将它们扔到了一边."使用正则表达式.

For example, in the following text, I'd like to extract the sentence "It was exactly as if a hand had clutched them in the centre and flung them aside." using regular expression.

我尝试使用这个 .*?抛出 (?.*?)\.,但它从行的开头开始搜索.

I tried to use this .*? flung (?<sub>.*?)\., but it starts searching from the beginning of the line.

我该如何解决问题?

就在她这样做的时候,一件最不寻常的事情发生了.被褥聚拢在一起,猛地一跃而起,变成了一座山峰,然后一头扎进了底栏.就好像一只手将他们抓在了中间,然后扔到了一边.紧接着,…………

As she did so, a most extraordinary thing happened. The bed-clothes gathered themselves together, leapt up suddenly into a sort of peak, and then jumped headlong over the bottom rail. It was exactly as if a hand had clutched them in the centre and flung them aside. Immediately after, .........

推荐答案

给你,

[^.]* flung [^.]*\.

演示

[^.?!]*(?<=[.?\s!])flung(?=[\s.?!])[^.?!]*[.?!]

演示

更多推荐

正则表达式提取具有匹配单词的整个句子

本文发布于:2023-11-02 12:08:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552356.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:句子   单词   正则表达式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!