问题描述
正则是硬伤,我只能瞎猫碰死耗子用可能性大的正则去蒙.实在是蒙不下去了,哪位前辈救救我吧!原匹配的文本过长,我只能贴一段类似的格式(多个格式相同的内容):"word":"hello","num":"456789","word":"world","num":"123456"要求:匹配word字段与num字段的值,并且num字段的值不能为123456
解决方案
解决方案二:
用这个JavaScriptSerializer
解决方案三:
strings=""word":"hello","num":"456789","word":"world","num":"123456"";MatchCollectionmc=Regex.Matches(s,"(?i)"word":"(\w+)","num":"(\d+)"");foreach(Matchminmc){if(m.Groups[2].Value=="123456"){continue;}Console.WriteLine(m.Groups[1].Value+","+m.Groups[2].Value);}
时间: 2024-09-20 09:31:54