这个根本不用正则replace就搞定了

解决方案 »

  1.   


    string str=":……页数:249……";
    System.Text.RegularExpressions.Regex  reg=new  System.Text.RegularExpressions.Regex(@"(?<Page>\d)",System.Text.RegularExpressions.RegexOptions.IgnoreCase);  
    System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
    for (int i = 0; i < m.Count; i++)
    {
    Response.Write(m[i].Groups["Page"].ToString());
    }
      

  2.   

    using System;
    using System.Text.RegularExpressions;namespace Example_LocalNumericFormat
    {
        class Program
        {
            static void Main(string[] args)
            {
                string s = "a页数:249b页数5页数:250b";
                // \d 表示一个数字,+ 表示 1 个或多个连续的 \d
                // (?<= ) 左侧以指定字符开头才匹配.
                Match m = Regex.Match(s, "(?<=页数:)\\d+");
                Console.WriteLine("{0},{1},{2}.",m,m.NextMatch(),m.NextMatch());
                Console.Read();
            }
        }
    }
      

  3.   

    漏了点东西
    Console.WriteLine("{0},{1},{2}.",m,m = m.NextMatch(),m.NextMatch());
      

  4.   


            string s = "您现在的页数:832,共有9287页";
            string ptn = @"(?<=页数:)\d+";//注意这里环视 "页数:" 里的冒号分全角与半角,根本需要修改
            Match match = Regex.Match(s, ptn, RegexOptions.IgnoreCase);
            if (match.Success)
                TextBox1.Text = match.Value;
            else
                TextBox1.Text = "faild";