实现对一个字符串的处理,首先将该字符串首尾的空格去掉,如果字符串中间还有连续空格的话,仅保留一个空格,即允许字符串中间有多个空格,但连续的空格数不可超过一个.
string str = " dd d d ";
str = str.Trim();
string s = Regex.Replace(str, " {2,}", " ");
即:s
![](https://images.cnblogs.com/cnblogs_com/wupeiqi/662608/o_Warning.png)
string str = " dd d d ";
str = str.Trim();
string s = Regex.Replace(str, " {2,}", " ");
即:s