string input = " xx xxn ";
Console.WriteLine("操作前input={0},长度={1}",input,input.Length); //去除重复空格,连续空格替换为单个空格
input = Regex.Replace(input.Trim(), "\\s+", " ");
Console.WriteLine("操作后input={0},长度={1}", input, input.Length);
string input = " xx xxn ";
Console.WriteLine("操作前input={0},长度={1}",input,input.Length); //去除重复空格,连续空格替换为单个空格
input = Regex.Replace(input.Trim(), "\\s+", " ");
Console.WriteLine("操作后input={0},长度={1}", input, input.Length);
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。