productList.aspx?m=2&n=3&p=4
求怎么把m、n、p的值用正则表达式的\d去替换,这个写法该怎么写。
m、n、p不一定是一位数,可能是55...

解决方案 »

  1.   

    (?i)productList\.aspx\?m=\d+&n=\d+&p=\d+
      

  2.   

    参数用个aes加密就行了。接收再解密
      

  3.   


    <div class="bl_nt33U">                                                                            <div class="blnt_li2"><a href="productList.aspx?mid=58" class="58" level="3" id1="45" id2="47" >儿童床</a></div>                                                                            <div class="blnt_li2"><a href="productList.aspx?mid=59" class="59" level="3" id1="45" id2="47" >儿童书桌椅</a></div>                                                                            <div class="blnt_li2"><a href="productList.aspx?mid=60" class="60" level="3" id1="45" id2="47" >儿童衣柜</a></div>                                                                            <div class="blnt_li2"><a href="productList.aspx?mid=61" class="61" level="3" id1="45" id2="47" >收纳柜</a></div>                                                                            <div class="blnt_li2"><a href="productList.aspx?mid=62" class="62" level="3" id1="45" id2="47" >其他产品</a></div>
     
                                                             </div>  
    WebRequest wReq = WebRequest.Create(Url);
                WebResponse wResp = wReq.GetResponse();
                Stream respStream = wResp.GetResponseStream();
                StreamReader reader = new StreamReader(respStream, System.Text.Encoding.GetEncoding("utf-8"));
                str = reader.ReadToEnd();
                StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("../../") + furl_html, false, System.Text.Encoding.GetEncoding("utf-8"));
                
                //yourhtml是需要替换的,html是替换成的
                string yourhtml = @"(?i)productList\.aspx\?mid=\d+";
                string html = "";
                html = Regex.Replace(yourhtml, @"(?i)(?<=(['""]?))(\w+)\.aspx(\?[^?'""]+)?(?=\1)",
                delegate(Match ma) { return string.Format("{0}.html", ma.Groups[2].Value + ma.Groups[3].Value.Replace("&", "_").Replace("?", "_").Replace("=", "")); });
                str = str.Replace(yourhtml, html); 
                sw.Write(str);
                sw.Flush();
                sw.Close();兔子督察,帮忙看看,页面内类似yourhtml的内容没有替换掉,是什么原因?
      

  4.   

    你的 yourhtml 应该是上边那段HTML才对
      

  5.   

    上边那段就是str
    str = str.Replace(yourhtml, html);