Regular expression to extract whole sentences with matching word

前端 未结 4 935
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 06:20

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

4条回答
  •  广开言路
    2020-12-03 06:32

    Here you go,

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

    DEMO

    OR

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

    DEMO

提交回复
热议问题