#region 字符串中多个连续空格转为一个空格 /// <summary> /// 字符串中多个连续空格转为一个空格 /// </summary> /// <param name="str">待处理的字符串</param> /// <returns>合并空格后的字符串</returns> public static string MergeSpace(string str) { if (str != string.Empty && str != null && str.Length > 0 ) { str = new System.Text.RegularExpressions.Regex("[\\s]+").Replace(str, " "); } return str; } #endregion
原文地址:http://blog.csdn.net/jiankunking/article/details/46529495