能将 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
- 1 回答
- 0 关注
- 545 浏览
添加回答
举报
0/150
提交
取消