62,267
社区成员
发帖
与我相关
我的任务
分享
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());
另外可以用$1,$2...来引用具体的匹配内容,如
input : http://www.xxx.com/news/5/
replacement: /news.aspx?c=$2
pattern: http://(.*?)\.*xxx.com/news/(\d+)/*
结果为/news.aspx?c=5