日期:2014-05-17 浏览次数:20431 次
string strInput = @"selfDiscountInfoId:'',discount:'40',urgency:'false',isApplyKSeat:'false'"; string strPattern = "discount:'([^']+)',urgency:'([^']+)'"; Regex reg = new Regex(strPattern); Match m = reg.Match(strInput); string strCount = m.Groups[1].Value; string strGency = m.Groups[2].Value;
------解决方案--------------------
string s = "selfDiscountInfoId:'',discount:'40',urgency:'false',isApplyKSeat:'false'"; Match match = Regex.Match(s, @"discount:'(?<discount>.*?)',urgency:'(?<urgency>.*?)'"); Response.Write(match.Groups["discount"].Value + "<br/>" + match.Groups["urgency"].Value);