日期:2014-05-17 浏览次数:20817 次
string str = "1234456789 123 456"; Regex reg = new Regex(@"\s+",RegexOptions.IgnorePatternWhitespace); str=reg.Replace(str, " ");
------解决方案--------------------
string filename = @"c:\test.txt"; string s = File.ReadAllText(filename); string r = Regex.Replace(s, @"[\t ]+", " "); File.WriteAllText(filename, r);
------解决方案--------------------
string str="1234456789"; str=str.Replace("5","5 ");