首先, d考虑推送获取原始消息而不是诉诸于这些措施,因为结果不会很完美。
您可以使用正则表达式[\.\!\?]\b
,它被定义为标点符号,后面跟着单词的开头。
示例代码:
static void Main(string[] args)
{
Console.WriteLine(RestoreNewlines("This is the end of the first paragraph.And this is the start of the second. This is the start of the third."));
Console.WriteLine(RestoreNewlines("Example of a case.txt where it fails."));
}
private static readonly Regex PunctuationWithoutFollowingWhitespaceRegex = new Regex(@"[\.\!\?]\b");
static string RestoreNewlines(string input)
{
return PunctuationWithoutFollowingWhitespaceRegex.Replace(input, match => match.Value + Environment.NewLine);
}
输出:
This is the end of the first paragraph.
And this is the start of the second. This is the start of the third.
Example of a case.
txt where it fails.
来源
2015-09-04 19:49:32
Bas
PS,我会恢复的邮件,如果他们被查阅:他们被弹出通过他们使用的工具的服务器。 –