要求把这符串 后面的"_数字"替换为空
如:
aaa_bb_01==>aaa_bb;
aaa_cc_002==>aaa_cc;

解决方案 »

  1.   

    非要用正则吗?
       public string RemoveNum(string str)
        {
            return str.Substring(0, str.LastIndexOf("_"));
        }不就可以了! 欢迎加入 41308893 (asp.net 技术交流群)
      

  2.   

    To: love_study(我爱学习!) 
    你的方法不行,aaa_bb_01==>aaa;
      

  3.   

    string str = @"(?<=aaa_\w+)_\d+";
    string resultStr = Regex.Replace(yourStr, str, "");
      

  4.   

    Regex.Replace(str, @"(?<=_\w+)_\d+", "")偶的想法和 先知 的差不多。。呵呵
      

  5.   

    string result = Regex.Replace(input, "\d+$", "")