C# 整理

 

1、获取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;
        }

 

posted @ 2017-10-13 11:53  fo0ol  阅读(114)  评论(0编辑  收藏  举报