求一正则~! {"name":"北京","id":1001},{"name":"长沙","id":1002},{"name":"乌鲁木齐","id":1003}字符串如上:以{"name":"北京","id":1001}为一个单位匹配 北京 1001 部分可变,其他不变,数字长度也可变谢谢!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用C#写:using System.Text.RegularExpressions;//codestring str = "{\"name\":\"北京\",\"id\":1001},{\"name\":\"长沙\",\"id\":1002},{\"name\":\"乌鲁木齐\",\"id\":1003}";string pattern = @"{""name"":""(\w+)"",""id"":(\d+)}";System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(str, pattern);foreach (Match m in mc){ Response.Write(string.Format("name:{0}, id:{1}<br />", m.Groups[1].Value, m.Groups[2].Value));} 关于VS的问题 修改信息时如何调用存储过程!!!!!! 在线等待 Treeview动态树问题 索引必须位于该列表的界限内。参数名:index 谁见过viewstate的报这样的错啊? DataGrid无法显示数据的问题?? .NET发不出去邮件问题 大家用ASP.NET是用什么开发工具的? 关于.net的配置问题 MVC2下 IE6下不支持的 下拉框二级联动 求救: 我的WEB服务器IIS老是出现停机现象, 不知是何原因? 小弟是新手请教一个数据库更新的问题: 关于一个GridView取值并存入string[]的问题,急啊,5555555555
using System.Text.RegularExpressions;//code
string str = "{\"name\":\"北京\",\"id\":1001},{\"name\":\"长沙\",\"id\":1002},{\"name\":\"乌鲁木齐\",\"id\":1003}";
string pattern = @"{""name"":""(\w+)"",""id"":(\d+)}";
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(str, pattern);foreach (Match m in mc)
{
Response.Write(string.Format("name:{0}, id:{1}<br />", m.Groups[1].Value, m.Groups[2].Value));
}