C# 使用正则表达式拆分句子
我想将文本(使用正则表达式)拆分为一个点后跟一个空格或一个点后跟一个新行(\n) 我在与c#Net合作 感谢你的回答 正则表达式C# 使用正则表达式拆分句子,c#,regex,split,C#,Regex,Split,我想将文本(使用正则表达式)拆分为一个点后跟一个空格或一个点后跟一个新行(\n) 我在与c#Net合作 感谢你的回答 正则表达式 /\.\s/ 将匹配后跟空格的文本。不需要正则表达式。只需使用字符串的重载string.Split,它接受一个字符串数组: using System.Text.RegularExpressions; string[] parts = Regex.Split(mytext, "\.\n|\. "); # or "\.\s" if you're not picky a
/\.\s/
将匹配后跟空格的文本。不需要正则表达式。只需使用字符串的重载
string.Split
,它接受一个字符串数组:
using System.Text.RegularExpressions;
string[] parts = Regex.Split(mytext, "\.\n|\. ");
# or "\.\s" if you're not picky about it matching tabs, etc.
string[] splitters = new string[] { ". ", ".\t", "." + Environment.NewLine };
string[] sentences = aText.Split(splitters, StringSplitOptions.None);
C#中没有文字正则表达式(/…/)。