What is a regular expression for parsing out individual sentences?

前端 未结 6 932
攒了一身酷
攒了一身酷 2020-11-27 18:16

I am looking for a good .NET regular expression that I can use for parsing out individual sentences from a body of text.

It should be able to parse the following blo

6条回答
  •  清酒与你
    2020-11-27 19:19

    var str = @"Hello world! How are you? I am fine. This is a difficult sentence because I use I.D.
    Newlines should also be accepted. Numbers should not cause sentence breaks, like 1.23.";
    
    Regex.Split(str, @"(?<=[.?!])\s+").Dump();
    

    I tested this in LINQPad.

提交回复
热议问题