string t1="/mpic/s4715249.jpg";
string t2="/mpic/s4749.jpg";
取/mpic/s后面的数字怎么取?  .jpg不要哦

解决方案 »

  1.   


    string t1="/mpic/s4715249.jpg";
    string t2="/mpic/s4749.jpg";
    string pattern = @"/mpic/s(\d+)\.jpg";
    string r1 = Regex.Match(t1,pattern).Groups[1].Value;
    string r2 = Regex.Match(t2,pattern).Groups[1].Value;
      

  2.   

                Regex reg = new Regex(@"(?i)(?<=/mpic/s)\d+");
                MatchCollection mc = reg.Matches(yourStr);
                foreach(Match m in mc)
                {
                    richTextBox2.Text += m.Value + "\n";
                }