比较难的正则,大侠帮忙呀!谢过了 ({result: ("A":{1,2,3}, "B":{4,5,6}, "C":{7,8,9}, total:26)})取其中的"A":{1,2,3}、"B":{4,5,6}、"C":{7,8,9}等这个group,如何写正则表达式? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 :\s*\(split结果,在用(?<=}),split 那么多的,号,你怎么个splite法呀?最好用正则来做 using System;using System.Text.RegularExpressions;public class Test{ static void Main(string[] args) { string str = @"({result: (""A"":{1,2,3}, ""B"":{4,5,6}, ""C"":{7,8,9}, total:26)})"; MatchCollection mc = Regex.Matches(str, @"""[A-Z].*?}"); int count = mc.Count; if (count > 0) { Console.WriteLine("存在数据"); for (int i = 0; i < count; i++) { Console.WriteLine(mc[i].Value); } } else { Console.WriteLine("什么都没有"); } Console.ReadKey(); }}results:存在数据"A":{1,2,3}"B":{4,5,6}"C":{7,8,9} MVC视图呈现问题 请问:如何做限制使在textbox中只能输入英文? 用过AjaxPro.2.dll的朋友进来帮帮忙,多谢了!!! 怎样在C#.NET中进行XML串行化的传输 不能输入----学习C#中对于文件操作的问题 很意外 NET2003混淆器 谁帮忙看看这一段代码? 单独开贴给对我有帮助的人、、brightheroes 急!急!一个很常见的知识 请问在做winform时,为什么debug中文件夹中会出现Awesomium.dll和icudt42.dll文件? 查询结果在datagrid上显示的问题 为什么我的数据库不可附加外来的数据类!!!
using System;using System.Text.RegularExpressions;public class Test
{
static void Main(string[] args)
{
string str = @"({result: (""A"":{1,2,3}, ""B"":{4,5,6}, ""C"":{7,8,9}, total:26)})"; MatchCollection mc = Regex.Matches(str, @"""[A-Z].*?}");
int count = mc.Count;
if (count > 0)
{
Console.WriteLine("存在数据");
for (int i = 0; i < count; i++)
{
Console.WriteLine(mc[i].Value);
}
}
else
{
Console.WriteLine("什么都没有");
}
Console.ReadKey();
}
}results:
存在数据
"A":{1,2,3}
"B":{4,5,6}
"C":{7,8,9}