如何用正则将 
"/Product/ProductView/1235.shtml" 转为 "/Product/ProductView.aspx?ID=1235"
'/Product/ProductView/1235.shtml' 转为 '/Product/ProductView.aspx?ID=1235'不区分大小写谢谢

解决方案 »

  1.   

    '/Product/ProductView.aspx?ID=1235' 转为  '/Product/ProductView/1235.shtml'是这样的html = System.Text.RegularExpressions.Regex.Replace(html, @"(['""]?)(/Product/ProductView.aspx\?ID\=)([^"">].*)(\1)", "$1/Product/ProductView/$3.shtml$4", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
      

  2.   


    string text = "<a href=\"/Product/ProductView/1235.shtml\"><a href='/Product/ProductView/1235.shtml'>"; 
    string s=System.Text.RegularExpressions.Regex.Replace(text,@"(['""]?)(/Product/ProductView/)(\d+)(.shtml)(\1)","$1/Product/ProductView.aspx?ID=$3$5",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    Response.Write(s);
      

  3.   


    "/Product/ProductView/(\d+).shtml" 转为 "/Product/ProductView.aspx?ID=1235" 
    我都是这么做的
      

  4.   

    笔误应该是"/Product/ProductView/(\d+).shtml"         "/Product/ProductView.aspx?ID=$" 
      

  5.   

    连错2次应该是"/Product/ProductView/(\d+).shtml"         "/Product/ProductView.aspx?ID=$1" 
    忘了加  $1   了