是这样的,有一些文本文件
内容如下:
12377328879?
12394201323 ?
12310584345?
12396001563?
12317177361 ?
12317220233?
............
............也就是很多数字后面跟了"?"和空格
怎样把多余的字符去掉?

解决方案 »

  1.   

    string str = "12377328879?";
    string ret = str.Replace(" ", string.Empty).Replace("?", string.Empty);
      

  2.   

    Regex rx = new Regex(@"[\s?]+");
                //测试
                string str = "12345573372  ?";
                str = rx.Replace(str, "");
                Console.WriteLine(str);
      

  3.   

    别忘了:using System.Text.RegularExpressions;