日期:2014-05-18  浏览次数:20350 次

给定一个uri,怎么获取里面的参数值?
比如 uri="http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=e2798a59-79d5-4833-9c57-87d46a8b907a"

怎么获取里面的 forumID的值???

------解决方案--------------------
IndexOf('?')
Split('&')
------解决方案--------------------
参照
C# code

string url="http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=e2798a59-79d5-4833-9c57-87d46a8b907a";
string[] urlArrays=url.Split('forumID');
string aStr=urlArrays[0];

------解决方案--------------------
System.Text.RegularExpressions.Regex reg=new System.Text.RegularExpressions.Regex("a=([^&]+)");
Uri uri = new Uri("http://www.contoso.com/catalog/shownew.htm?date=today&a=1&b=2");
System.Text.RegularExpressions.Match match= reg.Match(uri.Query);
string a= match.Groups[1].Value;