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

标签 c# split

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

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

例子:

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/

相关文章:

c# - 从两个列表c#中获取匹配项的最快方法

c# - C# 中的字节数组加密

c# - 无法使用Web API中的外部身份验证提供程序创建新用户(Visual Studio 2013 Update 2)

SQL-将字符串拆分为多列

python - 如何根据冒号或连字符拆分字符串?

c# - C# 中的枚举 bool 值

c# - 缩小图像质量损失

Java 在包含空格的字符串中用逗号分割

r - 如何将键/值字符串转换为不同的行?

html - 你如何处理/操纵拆分图像