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);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2021-10-22
  • 2021-05-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案