/// <summary> /// URL参数取参数值 /// </summary> /// <param name="paramString">url</param> /// <param name="name">参数名</param> /// <returns></returns> public static string GetValueFromQueryString(string paramString, string name) { if (!string.IsNullOrEmpty(paramString)) { //分组正则 Regex reg = new Regex("(^|&|\\?)(?<name>[a-zA-Z]*)=(?<value>[^&]*)(&|$)"); //匹配集合 MatchCollection m = reg.Matches(paramString); foreach(Match match in m) { if (match.Groups["name"].Value == name) { return match.Groups["value"].Value; } } } return ""; }
时间: 2024-11-05 19:33:37