如何在C#中用特殊字符替换字符串中的多个空格?
我有一个字符串:
Hi I am new here. Would you please help me?
我希望得到以下输出结果:
Hi I$am new$here. Would$you$please help$me?
我尝试过
string line=@"Hi I am new here. Would you please help me?";
string line1 = Regex.Replace(line,@"[\s\s]+","$");
Console.WriteLine(line1);
但是我的输出结果变成了:
Hi$I$am$new$here.$Would$you$please$help$me?
请问我哪里出错了?