str="A B C D E F"; str = new System.Text.RegularExpressions.Regex("[\\s]+").Replace(str, " "); //结果 //# A B C D E F