我需要从 Url.PathAndQuery 中删除任何“&id=SomeValue”。其中 SomeValue 可以是整数或字符串。它后面可能有也可能没有另一个 & 符号。
所以它可能是
somepage.aspx?cat=22&id=SomeId¶m2=4
or
somepage.aspx?cat=tect&id=450
我想留下
somepage.aspx?cat=22¶m2=4
or
somepage.aspx?cat=tect
就这样从我的头顶上消失了......
string url = "somepage.aspx?cat=22&id=SomeId¶m2=4";
Regex regex = new Regex("([\?\&])id=[^\?\&]+");
url = regex.replace(url, "\1");
System.Diagnostics.Debug.WriteLine("url = " + url);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)