First Sentence Regex

前端 未结 7 2072
遇见更好的自我
遇见更好的自我 2021-01-20 03:54

I\'m after a regex ( php / perl compatible ) to get the first sentence out of some text. I realize this could get huge if covering every case, but just after something that

7条回答
  •  时光取名叫无心
    2021-01-20 04:13

    /\A(.+?)[.?!] /s
    

    matches everything until one of those punctuation marks followed by the space. that's what sentence is, isn't? dot should match new lines

提交回复
热议问题