码迷,mamicode.com
首页 > Windows程序 > 详细

c# 字符串中多个连续空格转为一个空格

时间:2017-03-02 12:29:04      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:res   end   sum   exp   replace   null   return   ace   text   

#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

c# 字符串中多个连续空格转为一个空格

标签:res   end   sum   exp   replace   null   return   ace   text   

原文地址:http://www.cnblogs.com/powerzhang/p/6489608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!