如何将periods
替换为spaces
,但保留...
?
string test = "This.is.a.test...";
test = test.Replace(".", " ");
答案 0 :(得分:5)
您可以使用此(?<!\.)\.(?!\.)
var regex = new Regex(@"(?<!\.)\.(?!\.)");
var ressult = regex.Replace("This.is.a.test..."," ");
Console.WriteLine(ressult);
输出
This is a test...