C# 整理

 

一、獲取url字符串中的參數url

 /// <summary>
        /// 從url裏獲取參數
        /// </summary>
        /// <param name="url">url</param>
        /// <param name="key">參數key</param>
        /// <returns>參數value</returns>
        private string GetUrlParamValue(string url,string key)
        {
            Regex urlRegex = new Regex(@"(?:^|/?|&)" + key + "=([^&]*)(?:&|$)");
            Match m = urlRegex.Match(url.ToLower());
            string value = string.Empty;
            if (m.Success)
            {
                value = m.Groups[1].Value;
            }
            return value;
        }
相關文章
相關標籤/搜索