gpt4 book ai didi

c# - 如果以句号结尾但不以包含小数的数字结尾,则拆分句子

转载 作者:太空宇宙 更新时间:2023-11-03 23:40:28 27 4
gpt4 key购买 nike

我想将我的文本拆分成句子,每个句子以 . 结尾,但不包括带小数点的数字。

我使用了拆分功能。但它将数字分成两部分,我不想拆分数字。

例子:

My package a mount is 85.5 daily, how can I make use of it. any body has an idea for that. please let me know.

应该拆分为:

My package a mount is 85.5 daily, how can I make use of it

any body has an idea for that

please let me know

最佳答案

Dmitry Bychenko 的回答很简单也很好,但是它会在 .(点)之后失去一个字符

var regex = new System.Text.RegularExpressions.Regex(@"(?<!\d)\.(?!\d)");
var myText = @"My package a mount is 85.5 daily, how can I make use of it. any body has an idea for that. please let me know.";

Console.WriteLine(regex.Replace(myText, Environment.NewLine));

它只会消耗既没有数字也没有数字的.(点)字符。

关于c# - 如果以句号结尾但不以包含小数的数字结尾,则拆分句子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29206926/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com