/// <summary>
/// 获取URL中指定参数值
/// </summary>
/// <param name="name">Key</param>
/// <param name="url">URL</param>
/// <returns></returns>
public static string GetQueryString(string name, string url)
{
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(@"(^|&)?(\w+)=([^&]+)(&|$)?", System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.MatchCollection mc = re.Matches(url);
foreach (System.Text.RegularExpressions.Match m in mc)
{
if (m.Result("$2").Equals(name))
{
return m.Result("$3");
}
}
return "";
}
推荐阅读