Regex regex = new Regex(@"/五金在线B2B网站/Company/Index-(\d{1,6}).html$");
Console.WriteLine(regex.ToString());
string str=regex.Replace("/五金在线B2B网站/Company/Index-18.html","~/Company/index.aspx?p_UserID=$1");
Console.WriteLine(str.ToString());这是从url重写的程序中截取的一段。不明白p_UserID=$1的作用。
从网上查到这样一段:
另外可以用$1,$2...来引用具体的匹配内容,如
input : http://www.xxx.com/news/5/
replacement: /news.aspx?c=$2
pattern: http://(.*?)\.*xxx.com/news/(\d+)/*
结果为/news.aspx?c=5没看明白