string s = "a b c"; string[] x = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string y = string.Join(" ", x);
string test = "张三 30 男 汉 族"; test = System.Text.RegularExpressions.Regex.Replace(test, @"[ ]+", " ");
string test = "张三 30 男 汉 族"; string s = Regex.Replace(test, @"\s", string.Empty); Response.Write(s);
//高 实在是高 二楼 我爱你 //高 实在是高 二楼 我爱你 //高 实在是高 二楼 我爱你 //高 实在是高 二楼 我爱你 string s = "a b c"; string[] x = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string y = string.Join(" ", x);
string test = "张三 30 男 汉 族"; string s = Regex.Replace(test, @"\s", " ");
string test = "张三 30 男 汉 族"; string s = Regex.Replace(test, @"\s{2,}", " ");