Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 替换字符串中的单个字符实例,保留多个字符不变_C#_Regex - Fatal编程技术网

C# 替换字符串中的单个字符实例,保留多个字符不变

C# 替换字符串中的单个字符实例,保留多个字符不变,c#,regex,C#,Regex,如何将句点替换为空格,但保留… string test = "This.is.a.test..."; test = test.Replace(".", " "); 您可以使用此( 看一看 var regex = new Regex(@"(?<!\.)\.(?!\.)"); var ressult = regex.Replace("This.is.a.test..."," "); Console.WriteLine(ressult); This is a test...

如何将
句点
替换为
空格
,但保留

string test = "This.is.a.test...";

test = test.Replace(".", " ");
您可以使用此

看一看
var regex = new Regex(@"(?<!\.)\.(?!\.)");
var ressult = regex.Replace("This.is.a.test..."," ");
Console.WriteLine(ressult);
This is a test...