就是去掉所有尾数123
比如:
sourcetxt="C:\program file\123\pro123123123"
targettxt="C:\program file\123\pro"
sourcetxt="abcd123123"
targettxt="abcd"

解决方案 »

  1.   

    String sourcetxt=@"C:\program file\123\pro123123123";
          String targettxt = Regex.Replace(sourcetxt,@"\d*$","");
      

  2.   

    感谢,有没有用Match匹配的正则表达式
      

  3.   

    string sourcetxt=@"C:\program file\123\pro123123123";
    sourcetxt=Regex.Match(sourcetxt,".*?(?=(123)+$)").Value;呵呵
      

  4.   

    String sourcetxt=@"C:\program file\123\pro123123123";
    Regex re=new Regex(@"123$");
    While(re.Match(sourcetxt).Success)
          sourcetxt= Regex.Replace(sourcetxt,@"123$","");
      

  5.   

    十分感谢,但没看懂
    cancerser(都是混饭吃,记得要结帖)的 ".*?(?=(123)+$)"
    (?=(123)+$)我知道代表的是123末尾的数
    但".*?"的?是什么意思呢
    我把这个"?"去掉,显示结果只会去掉最后1个123
      

  6.   

    不是很明白,但大概理解意思了
    感谢cancerser(都是混饭吃,记得要结帖)和mmqingfeng(漠漠青峰)
    结帖