如何用正则将
"/Product/ProductView/1235.shtml" 转为 "/Product/ProductView.aspx?ID=1235"
'/Product/ProductView/1235.shtml' 转为 '/Product/ProductView.aspx?ID=1235'不区分大小写谢谢
"/Product/ProductView/1235.shtml" 转为 "/Product/ProductView.aspx?ID=1235"
'/Product/ProductView/1235.shtml' 转为 '/Product/ProductView.aspx?ID=1235'不区分大小写谢谢
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);
"/Product/ProductView/(\d+).shtml" 转为 "/Product/ProductView.aspx?ID=1235"
我都是这么做的
忘了加 $1 了