当前位置:编程学习 > C#/ASP.NET >>

求大神 这个正则表达式如何写

({"stime":1378786556,"status":{"allow":true,"miphone":{"hdstart":false,"hdstop":true,"hdurl":"http://bbs.csdn.net","duration":null, "pmstart":false},"mibox":
{"hdstart":false,"hdstop":true,"hdurl":"http://bbs.csdn.net","duration":null, "pmstart":false}}})

这个json数据,我要用正则表达式取hdurl的值 怎么写哦,求求大神 --------------------编程问答-------------------- (?<="hdurl":")[^"]+(?=") --------------------编程问答-------------------- 注意,双引号在代码里要转义 --------------------编程问答--------------------
webData = "({""stime"":1378786556,""status"":{""allow"":true,""miphone"":{""hdstart"":false,""hdstop"":true,""hdurl"":""?a_dsfsdf"",""duration"":null, ""pmstart"":false},""mibox"": {""hdstart"":false,""hdstop"":true,""hdurl"":""?a_dsfsdf"",""duration"":null, ""pmstart"":false}}})"

Set regEx1 = New RegExp         ' 建立正则表达式。
   regEx1.Pattern = "(?<=""hdurl"":"")[^""]+(?="")"
   regEx1.IgnoreCase = True         ' 设置是否区分字符大小写。
   regEx1.Global = True         ' 设置全局可用性。
  Set Matches1 = regEx1.Execute(webData)   ' 执行搜索。
  For Each Match1 In Matches1      ' 遍历匹配集合。
  msgbox(Match1.Value)
  Next



不行呀 见鬼了 --------------------编程问答--------------------
引用 3 楼 cndoit123 的回复:
webData = "({""stime"":1378786556,""status"":{""allow"":true,""miphone"":{""hdstart"":false,""hdstop"":true,""hdurl"":""?a_dsfsdf"",""duration"":null, ""pmstart"":false},""mibox"": {""hdstart"":false,""hdstop"":true,""hdurl"":""?a_dsfsdf"",""duration"":null, ""pmstart"":false}}})"

Set regEx1 = New RegExp         ' 建立正则表达式。
   regEx1.Pattern = "(?<=""hdurl"":"")[^""]+(?="")"
   regEx1.IgnoreCase = True         ' 设置是否区分字符大小写。
   regEx1.Global = True         ' 设置全局可用性。
  Set Matches1 = regEx1.Execute(webData)   ' 执行搜索。
  For Each Match1 In Matches1      ' 遍历匹配集合。
  msgbox(Match1.Value)
  Next



不行呀 见鬼了


你不用转义符 /  吗?


人家都告诉你要转义的了
测试过,可用
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,