能将 http://domain.com/test/test.aspx?id=123&type=5
换成http://domain.com/test/default.aspx?par=test&id=123&type=5
类似这样的,就是把前面的URL的test取出放到URL参数中去
我用
string url="/test/test.aspx?id=123&type=5";
string pattern="/test/(?<user>)([A-Za-z0-9]+).aspx";
string temp="/test/default.aspx?par=$1";
Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
if (regex.IsMatch(url))
{
url= regex.Replace(url, temp);
}
结果返回的url 是
/test/default.aspx?par=test?id=123&type=5
对正则不是很了解- -b
UYOU