Split text into sentences in C#

前端 未结 4 506
栀梦
栀梦 2020-12-14 12:39

I want to divide a text into sentences. A sentence ends with (dot) or ? or ! followed by one or more whitespace characters followed and the next sentence starts with an uppe

4条回答
  •  臣服心动
    2020-12-14 13:26

    Try this (MSDN)

    char[] separators = new char[] {'!', '.', '?'};
    string[] sentences1 = "First sentence. Second sentence!".Split(separators);
    //or...
    string[] sentences2 = "First sentence. Second sentence!".Split('!', '.', '?');
    

提交回复
热议问题