本帖最后由 lshfong 于 2011-09-27 13:23:12 编辑

解决方案 »

  1.   

    string strPatten="_p-([0-9]+)_t";string result = Regex.Replace("aaaaaa_p-1_ttttt",strPatten,"",RegexOptions.None);
      

  2.   


    string strPatten="_p-([0-9]+)_t";
    string result = Regex.Replace("aaaaaa_p-1_ttttt",strPatten,"",RegexOptions.None);
      

  3.   


    string str = "aaaaaa_p-10_ttttt";
            string number = "12";
            string newstr = Regex.Replace(str, @"_p-(\d+)_t", "_p-"+number+"_t",RegexOptions.Singleline);
            Response.Write(newstr);
      

  4.   

                string str = "aaaaaa_p-10_ttttt";
                string result = Regex.Replace(str,@"(?<=_p-)\d+(?=_t)", "12");
                Console.WriteLine(result);