如题:我想从模板页(静态页中通过正则匹配查找出要替换的特殊字符)
静态页中特殊字符如下(红色的):
模板 
<html> <head> <title> {TB_Index_Title}  </title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body > <table height="100%" border="0" width="100%" cellpadding="10" cellspacing="0" bgcolor="#eeeeee" style="border:1px solid #000000"> <tr> <td width="100%" valign="middle" align="left"> 内容:  {TB_Index_Context}时间: {TB_Index_Date}</td> </tr> </table> </body> </html> 

解决方案 »

  1.   

    代码:string[] arrStr = new string[30];
            string strString = "内容: {TB_Index_Context}时间: {TB_Index_Date} </td> ";
            arrStr = macthValue("{TB_Index.*}", strString);
            Label1.Text = arrStr[0].ToString();
     public string[] macthValue(string regexStr, string htmlStr)
        {
            MatchCollection mc;
            Regex r = new Regex(regexStr);
            mc = r.Matches(htmlStr);
            int count = mc.Count;
            string[] arrStr = new string[count];        for (int i = 0; i < count; i++)
            {
                arrStr[i] = mc[i].Value;
            }
            return arrStr;
        }
    怎么搜出来的是:{TB_Index_Context}时间: {TB_Index_Date}   
    怎么把那个”时间:“给过滤掉?
      

  2.   

            private void button2_Click(object sender, EventArgs e)
            {
                string[] arrStr = new string[30];
                string strString = "内容: {TB_Index_Context}时间: {TB_Index_Date} </td> ";
                arrStr = macthValue("(?<value>{TB_Index.*?})", strString);            label1.Text = "";
                foreach (string s in arrStr)
                {
                    label1.Text += s;
                }
            }
      

  3.   

    arrStr = macthValue("{TB_Index[^}]*}", strString);