日期:2014-05-20 浏览次数:21030 次
            Match match = Regex.Match(str,"Accept:([^\r\n]+)", RegexOptions.IgnoreCase);
            if(match.Success)
            {
                string value = match.Groups[1].Value;
            }
------解决方案--------------------
(?i)Accept:.+
------解决方案--------------------
            List<KeyValuePair<string,string>> keyValueList = new List<KeyValuePair<string,string>>();
            MatchCollection matches = Regex.Matches(str,"Accept:([^\r\n]+)", RegexOptions.IgnoreCase);
            foreach(Match match in matches)
            {
                string value = match.Groups[1].Value.Trim();
                MatchCollection matches1 = Regex.Matches(value, @"([^=]+)=([^;]+);?", RegexOptions.None);
                foreach(Match match1 in matches1)
                {
                    keyValueList.Add(new KeyValuePair<string,string>(match1.Groups[1].Value,match1.Groups[2].Value));
                }
            }
            
            foreach(KeyValuePair<string,string> item in keyValueList)
            {
                // 穷举keyValueList可以提取所有Accept里面的键和值
            }