如何用C#中的一个空格替换字符串中的多个空格?
例:
1 2 3 4 5
将会:
string sentence = "This is a sentence with multiple spaces"; RegexOptions options = RegexOptions.None; Regex regex = new Regex("[ ]{2,}", options); sentence = regex.Replace(sentence, " ");