First Sentence Regex

前端 未结 7 2097
遇见更好的自我
遇见更好的自我 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:25

    I know you just want anything that works for now, but this mailing list post came up with /^[^\.]*\.\s/, and the subsequent post came up with ([\s\S]+?)\.( |\r|\n).

    Though these patterns seem only match for periods, it's up to you if you want to modify it to also match for other types of punctuation such as exclamation marks and questions marks.

提交回复
热议问题